Skip to content
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

Cache is not cleared when page is swiched from publish to draft #170

Closed
bonny opened this issue Feb 7, 2019 · 0 comments · Fixed by #174
Closed

Cache is not cleared when page is swiched from publish to draft #170

bonny opened this issue Feb 7, 2019 · 0 comments · Fixed by #174

Comments

@bonny
Copy link

bonny commented Feb 7, 2019

I've noticed that this plugin does not seem to clear the cache for page when the page for example change status from publish to draft. Also probably the same bug applies to a page the slug is changed, or when page is trashed.

I've tried this on two wordpress installations on different servers and the same problem occurs on both. I don't think I have and plugins installed that would interfere with the plugin..

Plugin caching method is "nginx Fastchi cache" and purge method is "Delete local server cache files".

To test:

  • create a page with slug "cache-test"
  • Save page and visit in a new private browser window /cache-test/ to see that the page is working and is cached.
  • Make a small change in the post title and update the post. Refresh the page in the private browser window and notice that the title is correctly changed, i.e. the page has been cleared from the cache.
  • Now change the page status from publish to draft and save the page. Refresh the page in the private browser window and the page is still there. It has not been cleared from the cache.

Reason for error:
When the cache is cleared it uses the page permalink. So in the first case it cleares the cache for page http://localhost/cache-test/ but in the second cache is tried to clear the cache for page http://localhost/?page_id=5 that has never been cached at all. And the reason for this is that get_permalink() does not return pretty permalinks for draft posts, it simply returns $permalink = home_url('?p=' . $post->ID);

Excerpt from the nginx helper log:

Purge post on transition post STATUS from publish to publish
Purging page ( id 5, blog id 1 ) 
- Purging URL | http://localhost/cache-test/
delete_cache_file_for: http://localhost/cache-test/
Purge post on transition post STATUS from publish to draft
- Purging URL | http://localhost/?page_id=5
delete_cache_file_for: http://localhost/?page_id=5
- - http://localhost/?page_id=5 is currently not cached ( checked for file: /var/run/nginx-cache/8/5e/fd315ecc4dc2e2315f09f1cb6efc85e8 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant