Always Uses Old Cache, doesn't refresh (.htaccess)

One big issue I am having with InfinityFree is that my websites always loads old cache, despite the fact that I’ve added a Cache-Control to disable caching my website (previously tried must-revalidate) in htdocs/.htaccess, which contains:

Cache-Control: no-cache, no-store, must-revalidate
ErrorDocument 404 /error/404.html

The ErrorDocument is working fine, however clearly not the cache control.

This is mostly an issue with mobile (iOS/Android) browsers, however also affects a few desktop browsers.

Please help, thanks.

The issue here is that your Cache-Control statement looks like a HTTP header, not a .htaccess rule.

Please try this rule instead:

Header set Cache-Control "no-cache, no-store, must-revalidate"

@Admin Thank you, sorry for my mistake.
But is there a way to fix the use of old cache (not loading the updated site/files) in some browsers? I don’t really want to disable all cache, as it makes my site load slower, but just to make sure it will be reloaded in every browser once it is updated/modified.

@Kamdroid said:
@Admin Thank you, sorry for my mistake.
But is there a way to fix the use of old cache (not loading the updated site/files) in some browsers? I don’t really want to disable all cache, as it makes my site load slower, but just to make sure it will be reloaded in every browser once it is updated/modified.

I’m sorry, but that’s just not how cache works. Cache works by having browsers download files once and store them for a while. Browsers can only check for new content by downloading the files from the server, therefore circumventing cache.

Cache is a tradeoff between performance and update frequency. You need to decide what balance works for you.

@Admin I was thinking of something like loading the resources from cache, then in the background load them not from cache and if they are not the same, replace the cache with those new resources.

Maybe that isn’t possible though.
I’ve decided to use max-age=3000, but if anyone knows a better way, please let me know.

Anyhow, thank you for your fast replies. :slight_smile:

@Kamdroid said:
@Admin I was thinking of something like loading the resources from cache, then in the background load them not from cache and if they are not the same, replace the cache with those new resources.

Maybe that isn’t possible though.
I’ve decided to use max-age=3000, but if anyone knows a better way, please let me know.

Anyhow, thank you for your fast replies. :slight_smile:

I think something like that would be possible in theory, but it would be very complicated to build something like that. And, with a setup like that, you would see just as many request as when you’d disable cache entirely.