Cloudflare can't cache two files with question marks

#1

These are 2 images from ultimate member profile photo. Folder “1” and “290”. Two of 80x80

These have question marks in links.

I have caching everything enabled and w3 total cache all (but don’t work for me css enalbed, only combine)

#2

Your caching level is probably “Standard” when you actually want it to be “Ignore query string”. If you dont want the query string every ignored you could also selectively apply it using a page rule.

#3

just to add to sandro, you probably have some plugin that change the url to prevent caching, pay attention to the numbers after the question mark, if they always changing cloudflare will not be able to cache them by default, as from cf point of view its different file, the caching is based of full url so

1.png?1

is not equal to

1.png?2

#4

To add more:

The method your website seems to be using is called “cache busting”, which is made to ensure your website always returns the correct version of a file.

Unfortunately, your web server uses a really bad method for cache busting: using the current Unix timestamp. The Unix timestamp is a number that increments every second, and as of posting this, it is ~1551383929, the one in your picture is 1551370352 (about equal to the time of your post). As pointed out by @boynet2, This means that the file will only be served from Cloudflare’s cache if a file is requested multiple times within the same second.

This is likely due to some sort of plugin or theme. Ideally, the question mark (query string) should be a hash of the file’s contents, eg ?id=<sha1 hash of file>, so if that’s possible with your plugin, try that.

#5

Yes i have standard cache’ing but this is profile photo - it is static. Then it should be cached normally. Load times are because of this bigger.

closed #6

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