Search code examples
javascriptruby-on-railsturbolinks

Check if turbolinks has a cache to determine when to display a loading spinner


I'm working on rails project in which I'm using turbolinks.

When a user clicks a link, I'd like to be able to check if Turbolinks has a cache for the page the user is going to. If it's not cached, I'd like to display a loading spinner.

I've checked the docs and looked into the data on the different Turbolinks events, but I haven't been able to find a way to do this.

Is there a way I can do this check?

Any help would be greatly appreciated.


Solution

  • I found using Turbolinks.controller.cache.snapshots gives a list of all cache snapshots.