Local JS is always REVALIDATED never HIT

Hi there,

It appears that all other content gets the cf-cache-status: HIT, but my local JS always gets REVALIDATED

Page rules are setup to Cache-everything, and this is working because the page html gets HIT responses.

Here’s my response headers for a sample .js file:
cache-control:public, max-age=604800
date:Tue, 16 Oct 2018 15:24:37 GMT
expect-ct:max-age=604800, report-uri=“https://report-uri.Cloudflare.com/cdn-cgi/beacon/expect-ct
expires:Tue, 23 Oct 2018 15:24:37 GMT
last-modified:Tue, 16 Oct 2018 15:03:56 GMT
vary:Accept-Encoding, Cookie

My Browser cache time is set to 3 days. (Not sure if it’s relevant: Running a WordPress, with WP SuperCahce and FVM, which creates my combined js files.)

Is there something else I should be doing?

Revalidated is an interesting status. Straight from the manual

REVALIDATED: REVALIDATED means we had a stale representation of the object in our cache, but we revalidated it by checking using either an If-Modified-Since header or an If-None-Match header.

and stale

STALE: resource is in cache but is expired, served from CDN cache because another visitor’s request has caused the CDN to fetch the resource from the origin server. This is a very uncommon occurrence and will only impact visitors that want the page right when it expires.

Can you post the URL of the JavaScript file?

Exactly what I found, so I would might expect it when you load the page once, but this happens every time I load any page, or do I misunderstand the term?


It was a report from GTMetrix that made me aware of the issue, but a chrome network analysis shows the same result.

Any ideas?

I can reproduce that issue. It seems only cached entries are REVALIDATED, as the first request was a MISS and only all subsequent ones REVALIDATED.

I’d contact support in this case.

My closest guess at this point would be you might be sending some caching directives which render the file immediately expired and hence forces Cloudflare to check it against your server. Could that be the case?

But again, thats a guess.

the wordpress plugin you’re using at https://wordpress.org/plugins/fast-velocity-minify/ has it’s own static cache it seems ? maybe that is what Cloudflare is caching

Minification is done in real time and done on the frontend only during the first uncached request. Once the first request is processed, any other pages that require the same set of CSS and JavaScript will be served that same static cache file.

what happens if you turn off the minification/caching in that wp plugin ? and purge from both plugin cache and Cloudflare cache ?

Thanks for all the support!

So I’ve turned it off, and it does appear that all js files now are getting HIT correctly. However since nothing combines the files, there are over 50 individual js files. Any recommendations to auto combine them?

Or better still, I could alert the developer about this thread, but what should he change in the FVM plugin?

Thanks sandro, I was wondering though shouldn’t the cache everything page rule override this?

That would only instruct Cloudflare to cache everything. If your server still sends headers which make it expire immediately that might have a limited effect. I am afraid a lot here is mere guessing. The entire caching topic is not exactly the most straightforward one :roll_eyes:

Haha yes I’m finding that out the slow way :smiley:


Sandro your comment:

Got me thinking, if it’s someting on my server, it must be a .htaccess thing… So after looking at every htaccess file I found a htaccess made by the WP Super Cache plugin: public_html/wp-content/cache/.htaccess

Options -Indexes
# BEGIN supercache
<IfModule mod_mime.c>
  <FilesMatch "\.html\.gz$">
    ForceType text/html
    FileETag None
  AddEncoding gzip .gz
  AddType text/html .gz
<IfModule mod_deflate.c>
  SetEnvIfNoCase Request_URI \.gz$ no-gzip
<IfModule mod_headers.c>
  Header set Vary 'Accept-Encoding, Cookie'
  Header set Cache-Control 'max-age=3, must-revalidate'
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html A3
Options -Indexes

# END supercache

Header set Cache-Control 'max-age=3, must-revalidate’
Changing to 7 days fixed the issue! I just don’t understand why it only affected my .js files. All the .html files are in a sub-directory and weren’t affected.

Anyway thanks everyone.


wow why would anyone set that as is ! Glad to see you resolved the problem

Since I don’t know why WP super cache used those settings, I found a better solution was to store the FVM cache in a folder outside of the .htaccess realm

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