s9y/Serendipity — pull request #56 by smoeding (2013-09-12 16:14:30+00:00)
Title: Add ETag header to style sheet for better caching.

This is for the 2.0 branch as discussed in pull request #49

This commit improves caching for the style sheet. Currently the style sheet uses an Expires header with a timestamp of one hour in the future. Therefore the style sheet will be downloaded again after one hour. This is probably redundant since the style sheet does not change that often.

The change introduces the ETag header for the style sheet using a hash value of the CSS code. After the expiration time the browser will try to get the style sheet again using a If-None-Match header. The code calculates the hash again and sends a HTTP 304 Not Modified header when it is still the same. This saves bandwidth by not sending the complete style sheet again.