EllisLab/CodeIgniter — pull request #963 by atiredmachine (2012-01-24 21:47:49+00:00)
Title: Output class sends HTTP headers to match file caching settings

Employs both "Last-modified" and "Expires"/"Max-age" types of http headers for browser-side caching.

Browsers will now check with a "if-modified-since" header whether the version of the page in the browser cache is stale. CodeIgniter will check the last-modified date of the cache file and respond with a "304/Not modified" header instead of resending the exact same content. This results in faster page loads and less bandwidth consumption. Search engines also adhere to this rule, and so a site with a large amount of cached content can save considerably on bandwidth costs.

Still, this first method requires a response from the server before the cached page is rerendered by the browser.

The "expires"/"max-age" http headers avoid even this. All the checks are internally. The only possible issue is if a developer had manually flushed the file cache (or has written some routine that does this), the browser cache will have no way of knowing and will continue to serve of stale content until the original expiration or until they "refresh" the page. This is an edge case, but if it's an issue perhaps it might make sense to have a config setting so developers can choose whether they prefer this behavior or not.