-
Notifications
You must be signed in to change notification settings - Fork 810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Root index.html deleted unpredictably #25581
Comments
Below is an extract from the debug file. It shows what happens when wp-cron.php is running and when a user is signing in.
To me, the clearing of rebuilt files should not be happening in both cases shown above. |
See https://wordpress.org/support/topic/root-indexhtml-is-deleted-unpredictably-after-the-last-update?replies=6 for a potential fix: In the plugin file wp-cache-phase2.php, the method that's doing the delete is: function wp_cache_ob_callback. The code block down on line 317 is being entered:
I temporarily updated my code to skip that rebuild logic when the current page is one that's flagged to not cache. so my line 317 became:
Don't yet know if this will have any negative side-effects (such as stranding old cache page copies), but I'm preloading the cache regularly so those cache page copies will still update with each preload run. |
P.S. I am having this problem so interested in a fix. |
Looking at the code, there is a similar check setting It is unclear to me why this is the correct fix. Because I think that for home page, $_SERVER['REQUEST_URI'] is either '' or '/' and this is a trivial match to any of the strings in $autorejected in wp_cache_is_rejected. As we can see from the debug log, it is a post request which is setting $cache_this_page to false (which is correct - we should not cache post request pages), but that is no reason to delete the existing cache. It seems to me that there may be two problems here:
What do others think? |
For issue 1, my proposed fix is from:
to:
Note: Not yet tested this. |
My proposed fix for issue 2 is from:
to:
|
I am not going to have time to test these for a few days. If someone else can test them then I will submit a PR if they work. |
As you can see I submitted PRs so that they can be evaluated by plugin owners. |
I'm facing the same problems plus an other : the precaching does not generate cache files for mobile. If i test with a smartphone, the file is generated but deleted after 2 min. Do u think it's link ? |
Is it just mobile pages? (My sites are all responsive - so no special pages for mobile. So I have no experience of special mobile pages.) |
See also Automattic/wp-super-cache#98 for a discussion about doing cache page invalidation for pages and posts. |
The cache is generated for all files, except the mobiles ones and the index. I have a responsive site too, but the responsive (mobile) cache files are very welcome too. I try your fixes and it seems to work, at least for the 2 min delete of index. Thx you for the fix. |
The point about a responsive site is that the HTML is the same for both desktop and mobile screens - and it adapts depending on the screen width. So there are no special cache files for mobile screens on a responsive site. |
I know, but the mobile files where generated before and used by mobile. Or maybe, it was generated because i had wptouch installed (but disabled) and this is now the correct way to work with a responsive theme ? But i still don't understand, if it is, why the plugin don't use the "normal" files and still generate a xxxx-mobile.html / gz files. |
Finally I had some time to do a little testing. With the modifications the root index.html-file is no longer deleted when a user logs in to the WP dashboard. I did not test the behaviour for issues Automattic/wp-super-cache#102 and Automattic/wp-super-cache#103 yet, but will do if I find some time. |
In addition to my previous comment, it appears the cache rebuild function is also functioning properly again. Posted a comment on of the posts on the dev site and all cache files affected are marked '.needs-rebuild'. Although I am testing on a very small scale, I really like what I see :-). |
Is it just me or does release 1.4.8 still have this bug? I have been trying to work it out all day and just found this issue log. |
Yes, 1.4.8 still has this bug, but the fixes proposed by Sophist-UK are solving the bug for me. The fixes aren't yet in the official release. |
Hi. Seeing the exact same issue on 3 sites. Thanks. |
Seems enabling direct cache files for home page ( But another different issue arises: #25558 |
Hello! It seems that a year later the bug is still in the latest version. My objective is to solve the issue of the index cache being made every 2 minutes. I changed the code that Sophist-UK made for issue 1 and 2. Should I also implement the first change on line 317? It says it's temporary so I'm not sure... And the code is like Chinese to me. Thanks for the help. |
I think Automattic/wp-super-cache#186 fixes this. Can you try moving the line "$do_rebuild_list[ $dir ] = 1;" around like in that PR? |
Yes, everything is fine now. |
Not fixed. Every time I log into my wp-admin, the homepage cache is cleared. |
Issue is still in latest version 1.4.9. I finally got around to debugging this issue for sites/clients and can confirm that the 2 fixes above fix the issue. It would be great to get this committed. Before: After: |
The fix referenced above in Automattic/wp-super-cache#186 only appears to be a partial fix from what I can tell: When I select the "Preload Cache Now" option in the Preload tab, the fix referenced in Automattic/wp-super-cache#186 above appears to correct the problem of the initial root index.html page being deleted/removed. However, when the preloaded cached files are refreshed for the 1st time the root index.html file is not refreshed because the date/time stamp doesn't change. Shortly after the refresh is complete the original root index.html file gets deleted. The 2nd preload refresh recreates the root index.html cache file, and it was not removed until shorlty after the 3rd refresh. It appears that when the preloaded cached files are refreshed it will not refresh/recache the root index.html file if there is an existing one available, and then it deletes the existing shortly after the preload refresh is complete. The next refresh will created the root index.html file again and it will stick around until the next refresh where it will be deleted shortly after that refresh is complete. It appears this cycle continues to get repeated. |
In addition to my previous post, when I receive traffic to my sites home page and a preloaded index.html page is not available, one is created. However, the next preload refresh will not refresh that cache. Instead that cache will stick around for a while and then it gets removed/deleted at random, and a new one will be generated when my home page receives another traffic hit. It doesn't appear the garbage collector is removing the home page cache because the garbage collector email I get always states "deleting 0 files and directories". |
There seems to be two issues here. One to do with preload and the other to do with logging in/POSTing to files in the root directory (like wp-login.php). Have you tried the latest code here in master? Logging in results in an attempt to rebuild ....../wp-login.php/ but there are several extra checks there now including a call to realpath() and a check if it's a directory. realpath() converts the /wp-login.php/ into "/" and that then causes the rebuild to fail as well. I tested a preload and the root index.html wasn't deleted either now. Please try master but read this post first about the changes as there have been many. I want to get a release out in the next few days so it's very stable. |
I downloaded the master zip file(wp-super-cache-master.zip), and uploaded via Wordpress > Plugins > Add New. Upon activation I received some errors and noticed some problems in the admin menu area. I ended up changing the name of the plugin folder from (wp-super-cache-master) to (wp-super-cache) and everything appears to function normally after a refresh. Did I go about this the right way? |
I would have just copied the files from the master directory into the existing wp-content/plugins/wp-super-cache/ directory but that works too. The important bit is the name of the plugin directory which, as you found out, has to be wp-super-cache. Hopefully testing will go well. :) |
I will continue to test, but currently I have noticed a couple of things:
Hope that makes sense, |
First thing I did this morning was check to see what cache files were available via cpanel file manager, and I noticed:
After the 1st scheduled Preload Refresh I noticed:
After the 2nd scheduled Preload Refresh I noticed:
Throughout my testing today I also noticed:
|
Is it possible these files are being removed because of garbage collection? Are you using the debug log to track what the plugin is doing. You'll be able to find out why they're being deleted. Also, the front page is not generated by the preload. Oh, in Automattic/wp-super-cache#289 I fixed the tags and categories checkbox, so grab the updated master and copy the files in that over your current wp-super-cache install. |
The garbage collection email always states "deleting 0 files and directories". I tried to access the debug file but was given the following error: I am confident the preload is caching my home page as referenced above. I should note that I have a static home page. If I have a static home page is it plausible then that the preload is caching it? I have updated to the latest master copy. |
I should also note that the debug file error I received was when I attempted to access the file through the plugin link. I was able to to find the debug file on my hosting account, and the file is accessible and readable via Cpanel. I also double checked the preload cache of my home page. The preload refresh will create a cache of the home page, and the next preload refresh will NOT create a new cache and shortly after it removes/deletes the cache that was made from the previous preload refresh. I have confirmed that the index.html file is my home page preload cache. The preload generates the cache and if I visit my homepage and check the debug message at the end of the page source, the time stamps do match. If I then delete this index.html file and revisit my site it will generate a new index.html file with a new current time stamp. |
I monitored my cache files via cpanel, and a preloaded home page cache was available at the time. After a few minutes a preload refresh was performed at 16:15 and it did NOT create a new cache of the homepage. At 16:16 the homepage cache from the previous preload was removed. I checked all my garbage collector emails in that time frame and they all stated "deleting 0 files and directories". I am more than willing to send you a copy of the debug log, for the time frames referenced above, to review. |
Any chance on a fix for this soon? Homepage seems most important to have cached. |
Hmm, I'm having issue where index.html (homepage) is being deleted all the time. Like every second. (1.4.9) I've tried to debug, but it seems like it creates the index.html, but something deletes it. Maybe same issue as in this thread. |
The static index.html and index.html.gz are deleted unpredictably. This happens when the Cache rebuild option is checked and it appears to be triggered by posting to a php-file in the root directory.
There are several mentions in the support forums.
The text was updated successfully, but these errors were encountered: