Leverage browser caching

Hello, I have caddy installed (with the cache plugin). I have a website that I am trying to optimize using Google Insights, currently one of the messages that I am worried about and trying to fix is this one:

Leverage browser caching
Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

My site is an angular 4 application, I generated the dist directory using:

ng build --prod --aot

The files generated were:

  • 0.a5bf5e16db39b9b5dccf.chunk.js
  • index.html
  • styles.770f5ed7b71eade79f3e.bundle.css
  • 3rdpartylicenses.txt
  • inline.121330343c94dd916591.bundle.js
  • vendor.e4b26a7c2a31f646a8aa.bundle.js
  • /assets
  • main.59be42610199f6d81e80.bundle.js
  • favicon.ico
  • polyfills.83297be9e3b03db18e57.bundle.js

Then, the setting that I have for that site in caddy is as below:

mysite.com {
   root /the/path/dist
   cache {
	match_path /
        status_header X-Cache-Status
        default_max_age 55m
        path /tmp/caddy-cache

    header / {
      Cache-Control "max-age=86400"

I tought that only using the cache directive this problem would be fixed but it doesn’t, then I added the header for the Cache-Control. But,I am still receving that message. In what thing am I failing?
Thank you so much

I wouldn’t lose too much sleep chasing that perfect Google page speed score, it’s a good guide, but more theoretical than practical…

It should tell you which files in particular aren’t set, though. If you curl one directly, does it have the right header?

AFAIK, Google’s PageSpeed Insights only accepts cache age of 24 hrs or greater.

This. Look closely at Google’s pages, even they don’t follow their own rules. Unless you work in advertising in NYC, 85+ is an acceptable score.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.