#Caching when going back

1 messages · Page 1 of 1 (latest)

wary cedar
#

Hi, just wondering here. I am currently trying to add caching, using Cache-Control, but running into an issue with the fact that as soon as I hit the back button the request is "/?_data=routes/index", which means caching no longer works. Any way to avoid this?

daring zephyr
#

or why is it necessary for it to be a button?

wary cedar
daring zephyr
#

unless you aren't going to a specific route and tracking the location state mhm

wary cedar
daring zephyr
#

but sure send me it

wary cedar
wanton creek
#

If you click a link, click the back button, then click the link and back button again, everything will load from cache.

wary cedar
wanton creek
wary cedar
wanton creek
#

That is a "data" request as I mentioned above.

#

The initial request was a document request, so that data request on back has not yet been seen and entered into the cache.

#

It's a net new request.

#

How remix works:

  • initial load is a document request

  • if you click a <Link>, a data request is made for the new location

  • when clicking back, a data request will be made for the previous locations data (a net new request not yet seen or in cache)

  • if you click an <a>, a document request is made for the new location

  • when clicking back, a document request is made. This will come from cache as it's been seen before

#

"back" after clicking a <Link> isn't "back", it's a "new client side navigation to the previous location", this requres the ?data request

#

If you don't want data requests, remove <Scripts /> or don't render <Link>, only use <a>

#

Yes, it works fine.

wary cedar
#

Right, okay, I will try that! Thanks again!

wanton creek
wary cedar
#

Was just gonna ask if it had a repo, thank you, I will try it out later!