Hey all!
I've been experimenting with Astro's SSR features by making a little app to manage my family's cabin and noticed that pages don't seem to re-render when you navigate backwards through your browser history. *This can be a relatively serious issues especially when you are server-side rendering auth-gated content. *
**For example: **
- I login to my app on /login and am redirected to /
- I then navigate to /calendar
- I then navigate to /
- I then logout by navigating to /logout (which removes my session cookie, and deletes the session from the db) and am redirected to /login
- if I know click "back" on my browser, I'm able to navigate through all of the staticly rendered "pages" I saw when authenticated (note: if I manually refresh these pages they force me to the /login route as expected)
Is there a way to force a rerender in these cases? I'm guessing this is happening because the page is cached, is the fix as simple as adding no-cache headers to each page?
I do realize I can avoid this by shifting all of my logic to client-side islands Preact/React/Svelte/whatever but for most of what I'm doing HTML rendered at the server on request is more than enough! I would like to stick with that for everything except the highly dynamic parts 🙂
**Links and reproduction account: **
Repo: https://github.com/MykalMachon/cabin/tree/dev/packages/webapp
Example: https://cabin-dev.up.railway.app/
email: [email protected]
password: AstroTestTime123