Pagespeed - Leverage Browser Caching

As you might already guess by the title we tweak the broser caching this time...

Note: This is the second post of a series showing how to optimize a Pelican powered page with NGinx. In the first post we talked about compression.

Let's continue our mission to improve the overall experience of our blog. Within the server section of your NGinx configuration add a location plus file endings list with a expires setting:

server {
  ...
  location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 30d;
  }

  location ~*  \.(pdf)$ {
    expires 30d;
  }

You can choose different expires strategies per file type as seen in the snippet above.

After this optimizations we still have two resources with rather short cache settings:

  • The google analytics snippet
  • and Algolia search snippet.

Not sure how to improve on that...hm.

Show Comments