Page Rules: Cache Everything... But do Query String Changes Still Apply?


#1

Hi all,

I’ve currently got a page rule - to cache everything!

*.example.com/folder/*

The problem is… I cant seem to update files using the query strings using the caching level “standard” (Delivers a different resource each time the query string changes.)

So in this file…

example.com/folder/index.php

I have this line:

<script>/js/myFile.js?v=8djdj8d8</script>

So the index.php is in the “folder” where the page rule cache everything is applied.

BUT I’ve added a query string to try and force a new version of “myFile.js” – which is NOT in the folder with the cache everything page rule.

It just seems that the new version of the javascript file is never loaded - even with a query string. Do I need to add something into my page rule to allow query strings to update the files?

Thanks for the help


#2

The HTML being served is a cached version, so it is still referencing the old file. Your updated HTML referencing the new fils is not being retrieved by Cloudflare, so the client is not getting served the file which references the different javascript file. So you need to purge the html in order to upload the newer file which references different assets.


#3

Would this work as a way of using the “standard” caching level for any query string – then catching everything else to “cache everything”


#4

I haven’t tested, but your problem isn’t that the js file is being cached incorrectly. Query strings are intended to bust the cache, so it isn’t really necessary anyway.

When you increment the js file we retrieve a new version even with cache everything (assuming ignore query string is enabled and the html file referencing the object requests the incremented version). The problem is your HTML file that is cached asks for file.js?v=1 and just updating the file.js on your server to file.js?v=2 doesn’t matter because the HTML sent to the user tells the user’s browser to as for file.js?v=1. Until the HTM file is purged and replaced or expires from the cache the file referenced in the HTML remains unchanged. Without the updated HTML file from the origin there’s no way to reference the new file.


#5

This topic was automatically closed after 14 days. New replies are no longer allowed.