johannschopplich / kirby-vue3-starterkit

✨ Kirby + Vue SPA starter: automatic routing, i18n, SEO and more!
MIT License
206 stars 19 forks source link

Kirby caches path to assets? #32

Closed tobystokes closed 3 years ago

tobystokes commented 3 years ago

With following .env settings:

KIRBY_CACHE=true
VITE_SERVICE_WORKER=true
VITE_STALE_WHILE_REVALIDATE=true

If I regenerate the assets with npm run build, the path in <?= vite()->js() ?> doesn't get updated to the latest hash specified in the manifest, because _app-index.php is cached.

Let me know if I'm misunderstanding something here! Would it be enough to just exclude the home page from ever being cached?

johannschopplich commented 3 years ago

That's default behaviour of Kirby and intended if you have caching enabled. When you rebuild, you will have to delete the cache manually. For example, run:

npm run build && rm -rf storage/cache/example

A simpler solution would be to add a custom script. Consider adapting your package.json with a script to delete your cache folder without having to manually adjust the rm -rf script:

"scripts": {
  "kirby:flush-cache": "find storage/cache -maxdepth 1 -mindepth 1 -type d -exec rm -rf '{}' \\;",
  "build": "... && npm run kirby:flush-cache",
},