exstatic -- browser cache

Post on 12-Apr-2017

113 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

EXSTATIC[example.org’s statics]

http://

http://example.orghttp://

GET /Host: example.org

http://weka.com/iscool

200 OKContent-Type: text/html

http://weka.com/iscool

<img src=”foo.png”>

http://weka.com/iscool

GET /foo.pngHost: example.org

http://weka.com/iscool

200 OKContent-Type: image/png

http://example.org

http://example.org

http://weka.com/iscool

GET /foo.pngHost: example.org

http://weka.com/iscool

200 OKContent-Type: image/png

http://weka.com/iscool

200 OKContent-Type: image/png

Caching headers

Last-Modified

http://weka.com/iscool

200 OKContent-Type: image/pngLast-Modified: Wed, 22 Feb 2006 04:15:54 GMT

http://example.org

http://example.org

http://weka.com/iscool

GET /foo.pngHost: example.orgIf-Modified-Since: Wed, 22 Feb 2006 04:15:54 GMT

http://weka.com/iscool

304 Not Modified

Last-Modifiedallows you to perform

validity checkagainst cache’s resources

—and download only outdated resources

Expires

http://weka.com/iscool

200 OKContent-Type: image/pngExpires: Wed, 30 Mar 2012 19:16:20 GMT

http://example.org

http://example.org

Expiresno request

since it’s cached!or unless explicitly asked (refresh)

Set caching headers aggressively for all static resources.

— google pagespeed

<FilesMatch "\.(gif|jpg|js|css)$"> ExpiresDefault "access plus 1 year"</FilesMatch>

Caching headersTake advantage on client’s

caching mechanism—

and reduce requests

Revving

v2

http://example.org

http://example.org

The most effective solution is to change any links to them; that way, completely new representations will be loaded fresh from the origin server.

— Mark Nottingham

The most effective solution is to change any links to them; that way, completely new representations will be loaded fresh from the origin server.

— Mark Nottingham

trick

http://weka.com/iscool

<img src=”foo-v2.png”>

http://weka.com/iscool

GET /foo-v2.pngHost: example.org

http://weka.com/iscool

200 OKContent-Type: image/pngLast-Modified: Thu, 26 Feb 2006 05:19:12 GMT

http://example.org

v2

vX =

foo-{md5}.png

GET /foo-234569103.pngHost: example.org

RewriteEngine onRewriteRule (.*)(-[0-9]+)?(\.[^\.]*)$ $1$3 [L]

http://weka.com/iscool

200 OKContent-Type: image/pngLast-Modified: Thu, 26 Feb 2006 05:19:12 GMT

Revvingeffective brower’s trick to

bypass caching—

or make sure your user has the latest version

Cookieless domain

http://example.org

Cookie: hiHOha

http://weka.com/iscool

GET /foo.pngHost: example.orgCookie: hiHOha

http://weka.com/iscool

GET /foo.pngHost: example.orgCookie: hiHOha

http://weka.com/iscool

GET /foo.pngHost: exstatic.org

Cookieless domainMinimize requests!

—but maybe not in the “critical path”

Parallelize downloads

X concurrent connexions maxper hostname

host1 host2 host3 host4

Parallelize downloadsBypass browsers’

concurrent connexions limitation

Infra?

web1 web2 web3 assets

tagA tagA tagA tagA

tagA

tagB tagB tagB tagB

example.org

one.exstatic.orgtwo.exstatic.orgthree.exstatic.orgfour.exstatic.org

exstatic.org

COLOPHON

Antoine BERNIER (abernier)2011

EXSTATIC[example.org’s statics]

top related