Rails/Hotwire - don't cache Turbo frames on restoration visits

197 Views Asked by At

I have a page that contains a Turbo frame which loads some content from another URL using the src param.

Now when I click a link to navigate away from that page and then press "Back" in my browser, it's what Turbo calls a "restoration" visit, on which it displays the cached page without loading it again from the server.

This is exactly what I want EXCEPT for the Turbo frame - it should never be cached and always be reloaded from the URL it has as its src param.

How can this be done?

1

There are 1 best solutions below

1
On

The turbo-data-permanent attribute may be what you're looking for:

https://turbo.hotwired.dev/handbook/building#persisting-elements-across-page-loads