performancecachingcache-controlhttp2expires-header

Caching and HTTP/2


I'm on a site running on HTTP/2 and I realized the following caching setup:

cache-control:max-age=604800, private
etag:W/"115-54e8a25e7b187"
expires:Fri, 14 Jul 2017 11:39:45 GMT
last-modified:Tue, 02 May 2017 13:02:11 GMT

Some questions about this setup:


Solution

  • Answers to your questions:

    1. No it's not a problem. Cache-control is used in preference to Expiries if both are specified. Mostly though web servers set them to have equivalent values.

    2. Both ETag and Last-Modified are used for conditional responses with ETag used in preference (similar to Cache-Control and Expiries). Last-Modified has the benefit that it's more human readable, though ETags allow additional flexibility on defining this on something other than date. Though some implementations of Etags have issues (I don't recommend they are used for Apache servers for example as I describe here: https://www.tunetheweb.com/performance/http-performance-headers/etag/ ).

    3. HTTP/2 doesn't change anything in terms of caching so the same headers and controls are used as under HTTP/1. There are a lot of other performance benefits to it. Server Push however brings interesting questions on how to only push resources which are not in the cache (using cache-digests or some sort of cookie based system to tell the server what the client has already cached). But the basics of caching using the HTTP headers mentioned above stays the same.