xianmin / hugo-theme-jane

A readable & concise theme for Hugo
https://xianmin.github.io/hugo-theme-jane/
MIT License
918 stars 285 forks source link

Feature: cache busting #382

Open evgeny-kim opened 5 months ago

evgeny-kim commented 5 months ago

Hi. Thank you for your great template!

I'm currently setting up caching. It might be a good idea to implement cache busting. We could add a hash to all JS and CSS assets and allow them to be cached forever, and disable caching for HTML.

Here's my approach in more detail:

  1. Move scripts and CSS files from /static to /assets, fingerprint them
  2. Put Photoswipe under versioned path /static/lib/photoswipe/4.1.2/, now it can be safely cached
  3. main.js is already fingerprinted. We can transpile and minify it
  4. Update figure shortcode to allow page resources caching.

I got the latest built-in figure shortcode that makes use of page resources. A fingerprint is added to page resources. Other links are not changed. The original hugo-easy-gallery logic around "src", "link" and "thumb" parameters is preserved.

I also updated the full config with an example of Cache-Control settings.

Would be glad to hear your thoughts.