Add guidance on what Cache-Control headers should be used on assets
#73
Labels
documentation
Improvements or additions to documentation
Effort: hours
Used by the team when triaging
The example is specifically related to fonts, but is the same principle for all assets.
An issue raised by Ed on the x-gov channel where unstyled text is being seen between page loads. This is Arial to Transport changing over. In theory this shouldn't be occurring because by this point the font is already in the cache. But an assets actual usage is dictated by the
Cache-Controlheaders. For example, if a font is already in a browser cache but it hasCache-Control: max-age=0set, looking at the examples in the MDN docs:This revalidation is blocking the browser from using the font, even though it is in the cache. It takes 1-RTT (round trip time) from server to browser before the browser is allowed to use the font. This could be 100ms+ on poor performing servers / or users on poor connections.
We should add guidance on setting long-life
Cache-Controlheaders for assets. For example, 1 year is set on fonts served fromwww.gov.uk:cache-control: max-age=315360000If it is that we want this revalidation to occur we can use the
stale-while-revalidatedirective. But as these font files have changed only once in many years, it really isn't needed.The text was updated successfully, but these errors were encountered: