EE4 Wordpress W3TC cache conflict

Hi,

Recently I moved my wordpress site with W3TC plugin to new server and installed Easy Engine v4. I created domain with --cache parameter. After migration I noticed serious cache issues with css and other assets.

Cache purge from wt3c didn’t do anything to frontend. It was randomly object cached by EE4 new function and Wordpress had no control over it. I have used
ee site clean
But it brought only partial result.

Did somebody encountered this issue? How to disable random EE4 caching and let wordpress to control it again? By now website looks like a mess

I don’t have an answer to your question but I wanted to ask someone that is more knowledgeable on this – is installing W3TC with the --cache flag switched on counter intuitive? I mean you’ve got redis, nginx opcache etc all being handled by the server so I would assume that installing a further plugin on top of that would just mess things up or even slow things down due to unexpected effects?

1 Like

I had to turn off page and object cache in wt3c plugin since EE4 does it on its own. But must admit it is very unhandy to purge cache via ssh.
And I don’t know how long pages are cached.

You can purge the cache with the nginx helper plugin that EE4 has installed can’t you? I’ve got a purge cache button at the top of my wp dashboard toolbar. If for some reason it didn’t install the plugins for you, install these two. In nginx-helper, switch the cache type over to redis. The config fields should already be populated for you.


2 Likes

Since I migrated from another instance with EE3 I forgot about this plugin. It works. Thanks!

1 Like

Regarding your CSS and JS assets, make sure you’re removing query strings from them (use a plugin like Machete or Query Strings Remover) so they get cached. By default EE4 caches js/css for 1d (I don’t know why…) but you can make this longer by editing the conf file. If you want to do this, open up your ssh again and head over to /opt/easyengine/sites/yourdomain.com/config/nginx/conf.d/

Open up main.conf and scroll all the way to the bottom. You’ll see the following lines. Copy them to your clipboard, and then add a # at the beginning of each of these lines

       location ~*  \.(css|js)$ {
               expires 1d;
               add_header Cache-Control "public, must-revalidate";
       }

Save the file, and next we’ll head up one directory, back to /nginx/. Now we want to go into the custom directory and edit user.conf – We’ll add the following code to set the js/css expiration date to max (or 30d, or whatever you wish.)

       location ~*  \.(css|js)$ {
               expires max;
               add_header Cache-Control "public, must-revalidate";
       }

Save the file, and sudo ee site restart yourdomain.com

Thank you for the hint. This should be in FAQ or handbook sections (paths to nginx configs).

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