szepeviktor / w3-total-cache-fixed

A community driven build of W3 Total Cache. The aim is to continuously incorporate fixes, improvements, and enhancements over the official WordPress release of W3 Total Cache.
https://github.com/szepeviktor/w3-total-cache-fixed/releases
MIT License
237 stars 47 forks source link

Cache miss scenario, need help to find the cause of the problem relating to Cache getting missed every-time. #179

Closed ghost closed 7 years ago

ghost commented 7 years ago

I am using W3 Total Cache in my existing website for a project and want to use this fork for php7 compatibility, once I replaced the plugin with this version the cache is generated as expected in the CACHE Directory but when the pages are visited/rendered every-time it executes the code and display page instead of the cached version. It means it misses the cache every-time and page life cycle gets executed as usual without any performance benefit.

I have defined constant to re-locate the cache directory in wp-config.php using:

defined('W3TC_CACHE_DIR') || define('W3TC_CACHE_DIR', ABSPATH.'wp-content/XXXXXX');

Also, I am getting following notice in admin side plugin list page:

The Page Cache add-in file advanced-cache.php is not a W3 Total Cache drop-in. It should be removed.

amiga-500 commented 7 years ago

Hi @dharmang-gtl

Questions

  1. After modifying your wp-config.php file are the cache files being generated inside your new cache location or are they still appearing in the old location? As a heads up, just make sure you place your _define('W3TC_CACHEDIR', ABSPATH.'wp-content/XXXXXX'); beforerequire_once(ABSPATH . ‘wp-settings.php’); but after define(‘ABSPATH’, dirname(__FILE__) . ‘/’);

  2. Are you using Disk Enhanced or Disk Basic for page caching?

  3. If it's disk enhanced have you looked inside your .htaccess (i am assuming you are using an Apache server) to see that the rewrites are directing to your new cache location?

  4. As for the advanced-cache.php issue... are you using more than 1 caching plugin? There might be a conflict.

Thanks for the info Kimberly

ghost commented 7 years ago

Hi @amiga-500,

  1. The statement is at correct place with ABSPATH defined and cache files are generated in the new location.

  2. Disk Enhanced cache method is used.

  3. For apache server, .htaccess does not have the rewrites for redirection ( I will check that ) but it was working for older version of plugin.

  4. Not other that W3 Total Cache any caching plugin is used as of now.

amiga-500 commented 7 years ago

@dharmang-gtl , thx for the info...very strange..i just checked now in a fresh install and it works fine for me (new cache location and no advanced-cache.php error msg) and it also adds the necessary htaccess rewrites as needed.

it seems that the rewrites is the problem ..your rewrites aren't being added for some reason.

under w3tc's dashboard it has a comaptibility check button..can u click it and see if you spot anything unusual?

do you see any changes in ur htaccess file done by w3tc at all? e.g. minified rewrites, browser cache? anything?

amiga-500 commented 7 years ago

btw, the advanced-cache,php error is indicating that, that file wasnt written by w3tc...could be a relic of something in the past you did with another cacher that wasnt removed. can you open the file and search for _W3PgCache ...if its missing that is your problem for that. id recommend deleting that file and just refresh ur admin page to have it regenerated (assuming w3tc is still activated..otherwise just reactivating will regenerate it)

ghost commented 7 years ago

In .htaccess file, there are some rules added by W3TC related to mod_expires, mode_deflate, mod_headers etc for Browser Cache but the mod_rewrite part is missing.

Deleting the advanced-cache.php file has worked now that error is gone.

amiga-500 commented 7 years ago

@dharmang-gtl ,

I'm curious...is the _mod_rewrite_ module loaded on your server? Putting aside the missing w3tc rewrite lines, do u see any successfully deployed rewritecond or rewriterule lines at all being used in your htaccess? Sounds like that module just isn't available.

Under Performance > Dashboard > Compatibility Check button what does it show for _modrewrite? For example here is mine:

dashboard_w3_total_cache

ghost commented 7 years ago

Rewrite module is available and enabled, moreover, in our development environment, we checked that .htaccess is properly updated with Rewrite Rules but still the cache files are not generated when we access/refresh the pages.

The cache files were generated when we use sitemap.xml crawler available here: https://github.com/khromov/sitemap-cache-warmer

For your information, we are working on WordPress v4.6 and PHP7.

amiga-500 commented 7 years ago

Hi again...needs some clarification:

  1. Your last reply said ".htaccess is properly updated with Rewrite Rules but still"...so you're saying that Rewrite rules do exist in your htaccess file (and working) but none of these rules pertain to w3tc? Or are you saying the rewrite rules generated by w3tc (starts with: ## BEGIN W3TC Page Cache core ) is found within your htaccess file but only on your development environment?

  2. So your cache folder is currently empty and despite your having Performance > General Settings > Page Cache = Enabled ... no files are every generated inside despite browser visits or using your sitemap crawler (btw: w3tc has WP-CLI support so you can flush, prime sitemap cache, etc from the command-line as an alternative approach)

  3. If your rewrite rules are indeed being written successfully by w3tc on your dev side but no cache files are being generated then let's try a test by removing your custom CACHE dir line from wp-config (dont forget to Empty all cache from dashboard beforehand so as to generate the new folder location structure). I want to see if your cache files are able to generate inside the default location.

  4. I assume your Settings > Permalinks is something other than Plain, correct ?

This is an interesting issue to diagnose since i am unable to re-create the problem on my end. Everything works fine on my side. This is the first time i've heard your kind of problem This seems to suggest its not w3tc but something in your environment (ie, permissions).

Thanks for the info

amiga-500 commented 7 years ago

Forgot to add...

Good to know that your _advancedcache.php needed to be deleted to solve the other problem. So it sounds to me your environment wasn't correctly cleaned prior to installation (e.g. a previous cache plugin was manually deleted instead of deactivated first, or a plugin author didnt remove their _advancedcache.php prior to this e.g. the official w3tc 0.9.5.1's advanced_cache.php is not the same).

That being said...if it's not too much trouble we should hunt around for other traces of the older cache plugin and possibly do a clean install of this because it doesn't seem like this is a bug with w3tc but could be some kind of plugin conflict or an environment setting.

You might want to write down your config settings or use the export config feature (if necessary):

  1. Delete all cache (via Dashboard > Empty all Cache button)
  2. Deactivate the W3 Total Cache plugin
  3. Delete the W3 Total Cache plugin from the wp-content/plugins folder.
  4. Remove this line from wp-config.php file: define(‘WP_CACHE’, true)
  5. Delete advanced-cache.php, db.php, object-cache.php files found inside wp-content folder
  6. Delete the entire w3tc-config folder from the wp-content folder.
  7. Delete the cache folder if it exists and your custom cache folder also within wp-content
  8. Check your .htaccess file. If you see any code added by W3 Total Cache, remove it

Once that is out of the way and you reinstall then we can at least eliminate one other possible reason for why your problem was occurring.