Skip to main content

Client HTTP Caching in Rails

Popularity Report

Total Popularity Score: 0

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Rank

Bookmark History

Saved by 2 people (1 private), first by anonymouse user on 2007-05-06


Public Sticky notes

Of all the available caching methods, client caching is both one of the most powerful, and most overlooked. I admit, I’m guilty of this myself! So what is client HTTP caching? I’m referring to the conditional If-Modified-Since HTTP requests issued by the browser/spider (Section 14.25) The idea is simple, when you submit a request to the server, you stuff a date into the ‘If-Modified-Since’ header and the web-server decides how to serve the request based on this timestamp. If the date you provided is equal to the last-modified date on the server, then a 304 header (Not Modified) is returned, and otherwise you browser starts fetching the actual file. Now, this is not a blanket caching method, but these requests are often used by RSS readers (check if the feed has been updated), and it is also a great way to cache dynamically generated objects (xml sitemaps, dynamic charts, etc.) Bottom line is, it’s virtually free, and it can dramatically lessen the load on the server - don’t overlook it!

Highlighted by missiontobe