0

I've been looking at some WordPress plugins, and I notice that if these plugins cache files, they will store these files in wp-content/cache/[PLUGIN_NAME]. Is there any particular reason why they store it there instead of inside their plugin directory?

The way I see it, the latter way allows the cached files to be deleted even if the plugin is deleted through (S)FTP.

  • Voting to close as "primarily opinion based" - I don't think there is a best answer for this, only opinions. Mine is: use wp-content/cache. Separate concerns, a plugin or even theme shouldn't write/delete files inside their own folder. Because then your wp-content/plugin/foo/ is different than mine. Also, people won't know and it might take very long to find (when changing hosts, URL, etc.), whereas wp-content/cache is one of the first things to clear when having problems – kero Jun 1 '18 at 10:33
1

When a plugin is updated, its folder gets deleted and recreated with the updated version. This would destroy any caches, which on a heavily trafficked site could bring down the server

Additionally, the plugins folder on a lot of servers is read only to the user the web server runs as for security reasons.

It also improves management. If you want to clear cache, you don't have to empty multiple folders across a site, when you have a single cache folder to clear out.

But keep in mind though, that all these plugins give tiny improvements when compared to the massive boost a dedicated object cache will provide. I strongly recommend a Memcached/Redis based setup.

Also, file based caches won't work on a lot of systems, e.g. on a busy cheap/shared host server, it might be faster to generate the page than it is to retrieve it from the disk, with the end result being that your site runs slower not faster

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.