Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cache for date-based archive views not cleared when post is updated #724

Closed
raamdev opened this issue Mar 23, 2016 · 11 comments
Closed

Cache for date-based archive views not cleared when post is updated #724

raamdev opened this issue Mar 23, 2016 · 11 comments
Assignees
Milestone

Comments

@raamdev
Copy link
Contributor

raamdev commented Mar 23, 2016

Steps to reproduce

  • Install Comet Cache Lite v160227, activate, enable.
  • Set Settings → Permalinks to Custom Structure: /%year%/%monthnum%/%postname%/
  • Publish a new post, then logout and visit that post to generate a cache file.
  • Visit the date-based archive view for the post, e.g., /2016/03/ to generate a cache file that includes that post.
  • Now login and edit the published post, change it in some way; click 'Update' to update the post.

Expected behavior

All cache files associated with the post are cleared, e.g., the post cache itself, and the date-based archive view that includes the post (/2016/03/).

Observed behavior

The post cache, category archive cache, and tag archive cache files all get cleared as expected, but the date-base archive cache does not. Visiting /2016/03/ shows an archive view that includes an old copy of the post (because that cache file was never cleared when the post was updated).

@raamdev
Copy link
Contributor Author

raamdev commented Mar 23, 2016

@jaswsinc I was looking through the Comet Cache Automatic Cache Clearing options and I realized that we don't even have anything for date-based archive views. Am I missing something or have we never had support for this? This seems like a pretty important thing to support, given that date-based archive views are on-par with category and tag archive views in terms of how often they're used.

@jaswrks
Copy link

jaswrks commented Mar 23, 2016

Am I missing something or have we never had support for this?

Great catch. I'm not seeing anything either.

This seems like a pretty important thing to support, given that date-based archive views are on-par with category and tag archive views in terms of how often they're used.

Agreed.

@jaswrks
Copy link

jaswrks commented Apr 8, 2016

I was just taking a closer look at this issue. The permalink structure should not matter, should it? If a Post is updated in some way (regardless of permalink) the date-based archive view should be cleared as well, when that functionality is enabled. Does that sound right?

So it seems like what we need is a routine that can look at the original publication date and then clear the date-based archive views for that publication date, regardless of permalink.

@raamdev
Copy link
Contributor Author

raamdev commented Apr 9, 2016

So it seems like what we need is a routine that can look at the original publication date and then clear the date-based archive views for that publication date, regardless of permalink.

Yes, that sounds right.

All we need to consider is that the date-based archive views may be paginated, and the post that's being updated might be somewhere other than page 1.

I just did some testing and it appears that for a post published on April 9th, 2016, we would need to clear all of the following:

/2016/*
/2016/page/*
/2016/04/*
/2016/04/page/*
/2016/04/09/*
/2016/04/09/page/*

It's unfortunate that the cache for a whole years' worth of archives will get cleared each time a post is published/updated, but I'm not seeing any way around this.

Also noting that we should use $GLOBALS['wp_rewrite']->pagination_base instead of page, as the slug may be different on some sites (e.g., sites that have translated it into their own language).


We should add a new option to Automatic Cache Clearing that allows a site owner to control this behavior:

Auto-Clear "Date Archives" Too?

  • Yes, if any single Post is cleared/reset, also clear the associated Date archive views. (default)
  • Yes, but only clear the associated Day and Month Date archive views.
  • Yes, but only clear the associated Day Date archive view.
  • No, don't clear any associated Date archive views.

@jaswrks
Copy link

jaswrks commented Apr 9, 2016

Copy that. Sounds like a plan then.

Also noting that we should use $GLOBALS['wp_rewrite']->pagination_base instead of page, as the slug may be different on some sites (e.g., sites that have translated it into their own language).

Agreed. Our existing code for regex formulation should already handle this properly. Once we implement a new method to clear the date-based archive views for dated variations as you outlined above, the pagination will be taken into account by some of our existing regex handlers.

@raamdev raamdev added this to the Next Release milestone Dec 21, 2016
jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Jan 27, 2017
jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Jan 27, 2017
… clear the cache for date-based archive views whenever any single post is cleared due to changes in content, title, etc. See: **Dashboard → Comet Cache → Plugin Options → Automatic Cache Clearing → Auto-Clear "Date-Based Archives" Too?**. See also: [Issue #724](wpsharks/comet-cache#724).
jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Jan 27, 2017
raamdev added a commit that referenced this issue Feb 1, 2017
- **New Feature:** Comet Cache can now be configured to automatically clear the cache for date-based archive views whenever any single post is cleared due to changes in content, title, etc. See: **Dashboard → Comet Cache → Plugin Options → Automatic Cache Clearing → Auto-Clear "Date-Based Archives" Too?**. See also: [Issue #724](#724).
- **New Pro Feature:** Apache Optimizations now include a new option that allows site owners to enforce an exact host name for all requests. See: **Dashboard → Comet Cache Pro → Plugin Options → Apache Optimizations → Enforce an Exact Host Name?**. See also: [Issue #101](#101).
- **Bug Fix:** Apache detection sometimes inaccurate. So instead of using default WP core globals for server detection, Comet Cache now uses it's own set of Apache/Nginx/IIS detection functions. And, this release enhances our Apache and Nginx detection routines; making them smart enough to catch additional edge cases; i.e., to further reduce the likelihood of there being a false-positive. See [Issue #748](#748).
- **Bug Fix:** Some XML-RPC and REST API requests were being cached inadvertently. See [Issue #855](#855).
- **Bug Fix:** Broken textarea field due to `white-space:nowrap` in Firefox. See [Issue #866](#866).
- **Bug Fix:** This release resolves empty directories being left in the cache folder, in some scenarios. See [Thread #866](https://forums.wpsharks.com/t/cache-folders-not-removed-during-clean-up-process/866).
- **Bug Fix** (Pro): Some REST requests were being redirected incorrectly whenever Apache Optimizations were enabled. See [Issue #855](#855).
- **Compatibility Bug Fix:** Some Jetpack API calls were being cached inadvertently. See [Issue #855](#855).
- **Enhancement:** Notes in HTML source now indicate fully functional on first load for improved clarity. See [Issue #860](#860).
- **Code Cleanup:** Enhancing security by removing `basename(__FILE__)` from direct access notices.
@renzms
Copy link

renzms commented Feb 6, 2017

Not working

Tested using

WordPress Version: 4.7.2
Current WordPress Theme: Twenty Seventeen version 1.1
Theme Author: the WordPress team - https://wordpress.org/
Theme URI: https://wordpress.org/themes/twentyseventeen/
Active Plugins: Comet Cache™ Pro v170201-RC
PHP Version: 7.0.10-2+deb.sury.org~xenial+1
MySQL Version: 10.0.29-MariaDB-0ubuntu0.16.04.1

Set Settings → Permalinks to Custom Structure: /%year%/%monthnum%/%postname%/

Steps to reproduce

Published a new post, and visited that post as a logged out visitor to generate a new cache file.

Create New Test Post

screen shot 2017-02-06 at 9 15 58 pm

Visited the date-based archive view for the post, /2017/02/ to generate a cache file that includes that post.

Archive

screen shot 2017-02-06 at 9 13 53 pm

Updated the published post, and cache files are cleared, the post cache itself, and Home Page cache.

Cache Cleared upon updating Post

screen shot 2017-02-06 at 9 16 18 pm

Front End Post Update and Cache Update

screen shot 2017-02-06 at 9 17 35 pm

Observed behavior

The post cache file all get cleared as expected, but the date-base archive cache does not.

Archive

screen shot 2017-02-06 at 9 19 20 pm

Manually clearing the cache will clear the Archive and generate a new cache upon visit:

screen shot 2017-02-06 at 9 20 12 pm

@jaswrks
Copy link

jaswrks commented Feb 9, 2017

Recording incorrect link formulation found during follow-up tests.

Array
(
    [1473911820 Date Archive] => https://jason.wpsharks.net/1473911820/
    [1473911820/1473825420 Date Archive] => https://jason.wpsharks.net/1473911820/1473825420/
    [1473911820/1473825420/ Date Archive] => https://jason.wpsharks.net/1473911820/1473825420/09/
)

@jaswrks
Copy link

jaswrks commented Feb 9, 2017

Recording correct link formulation after bug fix:

Array
(
    [2016 Date Archive] => https://jason.wpsharks.net/2016/
    [2016/09 Date Archive] => https://jason.wpsharks.net/2016/09/
    [2016/09/14 Date Archive] => https://jason.wpsharks.net/2016/09/14/
)

jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Feb 9, 2017
@jaswrks
Copy link

jaswrks commented Feb 9, 2017

@renzms Another great catch! Thank you.

This, along with the other issue in Apache Optimizations, have both been resolved now — in the release/170201-RC branch. ~ cc @raamdev

@renzms
Copy link

renzms commented Feb 10, 2017

Fix Confirmed Working for Comet Cache Pro v170209-RC

Original Archive Cache

screen shot 2017-02-10 at 5 05 30 pm

After updating post, cache is cleared for post as well as archive cache.

screen shot 2017-02-10 at 5 04 56 pm

Updated Archive Cache

screen shot 2017-02-10 at 5 06 08 pm

raamdev added a commit that referenced this issue Feb 20, 2017
- **New Feature:** Comet Cache can now be configured to automatically clear the cache for date-based archive views whenever any single post is cleared due to changes in content, title, etc. See: **Dashboard → Comet Cache → Plugin Options → Automatic Cache Clearing → Auto-Clear "Date-Based Archives" Too?**. See also: [Issue #724](#724).
- **New Pro Feature:** Apache Optimizations now include a new option that allows site owners to enforce an exact host name for all requests. See: **Dashboard → Comet Cache Pro → Plugin Options → Apache Optimizations → Enforce an Exact Host Name?**. See also: [Issue #101](#101).
- **Bug Fix:** Apache detection sometimes inaccurate. So instead of using default WP core globals for server detection, Comet Cache now uses it's own set of Apache/Nginx/IIS detection functions. And, this release enhances our Apache and Nginx detection routines; making them smart enough to catch additional edge cases; i.e., to further reduce the likelihood of there being a false-positive. See [Issue #748](#748).
- **Bug Fix:** Some XML-RPC and REST API requests were being cached inadvertently. See [Issue #855](#855).
- **Bug Fix:** Broken textarea field due to `white-space:nowrap` in Firefox. See [Issue #866](#866).
- **Bug Fix:** This release resolves empty directories being left in the cache folder, in some scenarios. See [Thread #866](https://forums.wpsharks.com/t/cache-folders-not-removed-during-clean-up-process/866).
- **Bug Fix** (Pro): Some REST requests were being redirected incorrectly whenever Apache Optimizations were enabled. See [Issue #855](#855).
- **Compatibility Bug Fix:** Some Jetpack API calls were being cached inadvertently. See [Issue #855](#855).
- **Enhancement:** Notes in HTML source now indicate fully functional on first load for improved clarity. See [Issue #860](#860).
- **Enhancement:** Enhancing security by removing `basename(__FILE__)` from direct access notices.
@raamdev
Copy link
Contributor Author

raamdev commented Feb 20, 2017

Comet Cache v170220 has been released and includes changes from this GitHub Issue. See the v170220 announcement for further details.


This issue will now be locked to further updates. If you have something to add related to this GitHub Issue, please open a new GitHub Issue and reference this one (#724).

@raamdev raamdev closed this as completed Feb 20, 2017
@wpsharks wpsharks locked and limited conversation to collaborators Feb 20, 2017
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

3 participants