Caching headers do not cooperate with Remix

Site: https://mikess.netlify.app/
Github: https://github.com/mikocevar/remix-netlify-demo

It should be a simple app and I still have issues with it.

Problem #1: If I visit the site, click a character and then click the browser back button, I get the error: TypeError: d.map is not a function.

The error is because the dataList from the useLoaderData(); is not an array. If I check for that and return an empty array the error goes away, but that is not the solution. If I set the cache headers to “private”, the issue goes away… but I want the caching?!

Problem #2: If I visit a character directly e.g.: https://mikess.netlify.app/1, click “go back” and then visit the character again through the main page: https://mikess.netlify.app/ I get no data. Again, that would probably go away without caching headers, but still, I want stuff to be cached.

I’m just trying to figure out the platform and play around and I get these issues with such basic examples. What am I doing wrong?

Regards, Mike

Hi, @mikocevar. You probably don’t want to modify Netlify’s default caching headers. There is a blog post with more details here: