Please sign in to comment.
Make pages cacheable.
This change, which probably shouldn't be in Theme, but can't seem to easily go anywhere else under the current design, should make all pages cacheable. First off it generates headers to make sure browsers actually try to cache the page. It may have been a server config on my side, but the max-age was always 0. Then we generate an ETag based on the current state of the page, in a really hacky way. If the ETag matches the HTTP If-None-Match header sent by the browser, we throw a 304 header and kill the connection. If the ETag doesn't match and we have loaded posts to display, we check the first (usually most recent) post's modified timestamp and generate a Last-Modified header. If the post's last modified timestamp is less than or equal to the HTTP If-Modified-Since header, we throw a 304 header and kill the connection. Lastly, if we haven't already matched anything, we'll just throw an Expires header for 30 days in the future and continue processing.
- Loading branch information...