This is a simple rails app with hotwire installed to demonstrate a potential caching issue as outlined here
bin/setup
rails s
# and in a separate terminal window:
bin/webpack-dev-server
- Navigate to localhost:3000/posts/new
- Create an unpublished post
- Click 'Publish' button on the post show page taking you to the index page
- Click the back button in the browser
The post show page should not be cached and show the "Unpublish" button.
The post show page has the cached "Publish" button still visible. Refreshing the page corrects the button to show "Unpublish".
Also if you click the "Show" link from the index page you will see a quick flicker on the button as it loads the cached page and then quickly replaces it.
Putting a console log at
node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js#l2108 confirms that the
call to this.view.clearSnapshotCache() happens.