Module:Cache Error

I’m guessing this is important judging by all the exclamation points. I keep seeing this in the error log when i visit

“…[ERROR]… [Module:Cache] vary request header “Origin” not defined!!!”

It’s a wordpress site running the LS Cache plugin. I’m getting the impression that it’s slow to load on first visit, as if it wasn’t using a cached version at all.

Any ideas?

it slow on first view because it hits the backend , not from cache.

I can not reproduce the issue on default WP, could you please DM me your site URL ?

The problem appears to be with the Contact page. It’s either the Contact Form 7 hooks that load its JS and CSS, or less likely, something with ReCaptcha. Still investigating…

Okay I cleared it up, no more error. It had to do with where I enqueued the contact form’s JS and CSS files.

If any random google search visitor finds themself here, here’s what’s working for me:

  • unload the two files inside functions.php
  • define a new function whose job it is to load them in
  • call that function in your template file for your Contact page

See Loading JavaScript and stylesheet only when it is necessary | Contact Form 7

I was wrong! It seems that the error actually comes from some sort of cache-busting(?) method that Contact Form 7 tries to call through JS.

Inside CF7s scripts.js, you’ll see

if ( wpcf7.cached ) {
wpcf7.refill( $form );

This refill method is what results in a 500 error on the page when it’s called. The method itself seems to use the Ajax setRequestHeader() method via jQuery. Inside of the response headers I can see “Vary: Origin”, and that might explain the OLS error message in the initial post.

So thanks to a bit of searching, my ‘solution’ is to modify the scripts.js file and changed the .cached property:

if ( wpcf7.cached ) {
wpcf7.cached = 0;

The form works fine and I no longer get the 500 error or the error message in my log.

Did you enable features like CSS/JS combine|minify|defer/async ? these feature might be messing with CF7’s script