Skip to content

Add ETag header to style sheet for better caching.

onli requested to merge github/fork/smoeding/stm/fix-css-etag into master

Created by: smoeding

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.

Merge request reports