Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with Wordpress and Varnish breaking loadscript.php

I've hit a snag with a Varnish - Nginx - Wordpress set up. The server is running multiple Joomla based sites (all fine) and should be running one Wordpress one too apart from it breaks with Varnish.

Basically when Varnish is enabled I get the following error:

Uncaught ReferenceError: _ is not defined on the Dashboard and various JQuery not defined errors elsewhere.

With Varnish off it all works perfectly. I'm scratching my head now as to where the issue lies with my Varnish set up. I can't find anything on the web that is a similar issue and any help would be appreciated!

like image 818
Rob Avatar asked Feb 10 '23 07:02

Rob


2 Answers

I just stumbled on this issue today. You didn't post your configuration, but my guess is that you might be using querysort to normalize your query parameters.

I found that querysort really doesn't like the load-scripts.php URLs. In a lot of cases, it ends up truncating the URLs. If you're using it, I recommend either not using it or making a special condition for it like:

if (req.url !~ "load-scripts\.php") {
  set req.url = std.querysort(req.url);
}
like image 66
Carl Avatar answered Feb 12 '23 22:02

Carl


Further to Carl's answer I found that stopping querysort for the whole wp-admin helped with this error within other plugins.

if (req.url !~ "wp-admin") {
  set req.url = std.querysort(req.url);
}
like image 23
sidonaldson Avatar answered Feb 12 '23 21:02

sidonaldson