Cache is king
-
Upload
edrone -
Category
Technology
-
view
86 -
download
0
Transcript of Cache is king
Cache
Maciej Mendrela
<url scheme>://<host>:<port>/<path>?query/#<frag>
uniform resource locator
(start line) GET /BUILD/ASSETS/IMAGES/LOGO.PNG HTTP/1.1
HOST: WWW.EDRONE.ME 80
http://edrone.me/build/assets/images/logo.png
MIME TYPE
application/javascript
Request message
[method] [url] [version][headers]
[body]
Full requestGET / HTTP/1.1Host: server.comConnection: keep-aliveUser-Agent: Mozilla/5.0(Windows NT 6.1; WOW64) Chrome/16.0.912.75 Safari/535.7Accept : text/html, application/xhtml+xml,application/xml;=0.9,*/*;q=0.8Referer : http://www.google.com/url?&q=edroneAccept-Encoding: gzip,deflate,sdchAccept-Language: en-US,en;q=0.8Accept-Charset: ISO-8859-1,uft-8;q=0.7,*;q=0.3
Response message
[version] [status] [reason][headers]
[body]
Full responseHTTP/1.1 200 OKCache-Control: privateContent-Type: text/html, charset=utf-8Server: Microsoft-IIS/7.0X-AspNet-Version: 2.0.50727X-Powered-By: ASP.NETDate: Sat, 14 Feb 2003 04:00:08 GMTContent-Lenght:17151
<html>...content
</html>
Status codes categories
Range
•100-199•200-299•300-399•400-499•500-599
Category
•Informational•Successful•Redirection•Client Error•Server Error
Popular one’s
Code/Reason
•200/OK•301/Moved Permanently•302/Moved Temporaily•304/Not Modifed•400/Bad Request •401/Unauthoized•403/Forbidden•404/Not found •500/Internal Server Error•503/Service Unavailable
Description
•Success!•Resource moved,don’t check here again•Resource moved, but check here again•Resource hasn’t changed since last retrival•Bad syntax?•Client might need to authenticate•Refused access•Resource doesn’t exist•Something went wrong during processing •Server will not recive the request
Cache-Control
Publicvs
Private
Max-Age = 0vs
No-Cache
Conditional request headers•Expect
•If-Match
•If-Modified-Since
•If-None-Match
•If-Range
•If-Unmodified-Since
•Range
•Allows client to list server behaviors that it requires for a request•Gets the document if the entity tag matches the current entity tag for the document•Restricts the request unless the resources has been modified since the specified date •Gets the document if the entity tags supplied do not match those of the current document•Allows a conditional request for a range of a document
•Restricts the request unless the resource has not been modified since the specified date•Request a specific range of a resource, if the server support range request
Apache modules
mod_expires
•ExpiresActive On •ExpiresByType image/jpg "access plus 1 year" •ExpiresByType image/jpeg "access plus 1 year„•ExpiresByType text/css "access plus 1 month„•ExpiresByType application/pdf "access plus 1 month" •ExpiresByType text/x-javascript "access plus 1 month" •ExpiresByType application/x-shockwave-flash "access plus 1 month" •ExpiresByType image/x-icon "access plus 1 year„•ExpiresDefault "access plus 2 days"
mod_headers
•<Files *.php> •Header set Cache-Control public,max-age=3600 </Files> •<Files *.xml> •Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0" •</Files>
Thank You!