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

`purge_cache` CRON Should Run Every Hour #472

Closed
jaswrks opened this issue Apr 20, 2015 · 13 comments
Closed

`purge_cache` CRON Should Run Every Hour #472

jaswrks opened this issue Apr 20, 2015 · 13 comments

Comments

@jaswrks
Copy link

@jaswrks jaswrks commented Apr 20, 2015

The zencache\plugin::purge_cache() method runs once daily (attached to WP Cron), in order to automatically cleanup expired/stale cache files. However, on a extrememly large site with a lower expiration time (to save disk space) it would be better if this routine ran hourly. That way an entire day has not gone by before ZenCache gets around to doing the cleanup; i.e., running hourly would make ZenCache smarter when configured in certain ways.

Referencing this internal ticket:
https://websharks.zendesk.com/agent/tickets/6002

@raamdev
Copy link
Contributor

@raamdev raamdev commented Apr 21, 2015

Great idea! I've marked this as ready for work and added it to the Next Release milestone.

@raamdev
Copy link
Contributor

@raamdev raamdev commented May 12, 2015

@jaswsinc Is there any reason we can't make this a configurable option? I.e., make the default 1 hour but allow a site owner to override that and specify an interval?

@raamdev raamdev modified the milestones: Next Release, Future Release Jun 5, 2015
@raamdev raamdev modified the milestones: Next Release (Pro), Future Release Jul 10, 2015
@jaswrks
Copy link
Author

@jaswrks jaswrks commented Sep 1, 2015

Is there any reason we can't make this a configurable option? I.e., make the default 1 hour but allow a site owner to override that and specify an interval?

We can make it configurable, yes. I don't see any problem with that. However, it does need to be on a schedule that is either already registered with WP-Cron, or that we add via filters.

@raamdev raamdev modified the milestones: Next Release (Lite), Future Release (Lite) Sep 30, 2015
@raamdev raamdev modified the milestones: v151107 (Lite), Future Release (Lite) Nov 7, 2015
@jaswrks
Copy link
Author

@jaswrks jaswrks commented Nov 12, 2015

Next Actions (Step 1 of 2)

  • New feature branch in the websharks/zencache-pro repo.

  • After this line add the following:

    'cache_cleanup_schedule' => 'hourly', // `every15m`, `hourly`, `twicedaily`, `daily`
  • Replace this line with the following:

    wp_schedule_event(time() + 60, $this->options['cache_cleanup_schedule'], '_cron_'.__NAMESPACE__.'_cleanup');
  • Replace this line with the following:

    if ((integer) $this->options['crons_setup'] < 1447330252 || substr($this->options['crons_setup'], 10) !== '-'.__NAMESPACE__.'-'.$this->options['cache_cleanup_schedule']) {
  • Submit PR.

@jaswrks
Copy link
Author

@jaswrks jaswrks commented Nov 12, 2015

Next Actions (Step 2 of 2 — On Deck)

  • New feature branch in the websharks/zencache-pro repo.
  • Add UI option (as described above) that allows a site owner to control:
    • cache_cleanup_schedule
  • Submit PR.

Note: The above instructions for Step 2 are rather vague. If you're able, attempt step 2 right away. Otherwise, once step 1 is complete hit me on Slack for a more complete set of Step 2 instructions.

@jaswrks
Copy link
Author

@jaswrks jaswrks commented Nov 12, 2015

Assigning this to @kristineds :-)

@jaswrks
Copy link
Author

@jaswrks jaswrks commented Nov 12, 2015

Related issue (#408) that we could tackle once this is done.

kristineds added a commit to wpsharks/comet-cache-pro that referenced this issue Nov 15, 2015
kristineds added a commit to wpsharks/comet-cache-pro that referenced this issue Nov 17, 2015
@raamdev raamdev modified the milestones: Next Release (Pro), Next Release (Lite) Nov 17, 2015
@raamdev
Copy link
Contributor

@raamdev raamdev commented Nov 17, 2015

@jaswsinc @kristineds It appears the option for this got added to the Auto-Cache Engine section of the UI, however from what I can tell this is not related to the Auto-Cache Engine but rather to Cache Expiration and therefore belongs in ZenCache → Plugin Options → Directory / Expiration Time.

The description for this option also needs to be updated to remove any mention of the Auto-Cache Engine.

kristineds added a commit to wpsharks/comet-cache-pro that referenced this issue Nov 18, 2015
@raamdev
Copy link
Contributor

@raamdev raamdev commented Nov 18, 2015

@kristineds @jaswsinc Also noting that the following text in Cache Expiration Time needs to be updated to reflect the new hourly schedule (it currently says "once daily", it should now say "once per hour"):

In addition, a WP Cron job will automatically cleanup your cache directory (once daily); purging expired cache files periodically.

kristineds added a commit to wpsharks/comet-cache-pro that referenced this issue Nov 18, 2015
kristineds added a commit to wpsharks/comet-cache-pro that referenced this issue Nov 18, 2015
@kristineds
Copy link

@kristineds kristineds commented Nov 18, 2015

@raamdev @jaswsinc That has been updated as part of the latest commit: wpsharks/comet-cache-pro@d702eeb

jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Nov 19, 2015
jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Nov 19, 2015
@raamdev
Copy link
Contributor

@raamdev raamdev commented Nov 20, 2015

Next Pro Release Changelog:

  • Enhancement: The automatic Cache Cleanup schedule that cleans up (deletes) expired/stale cache files has been changed from once every day to once every hour. Running the cleanup hourly makes ZenCache smarter when configured in certain ways and saves disk space. Props @kristineds. See Issue #472.
  • New Feature!: It's now possible to customize the Cache Cleanup Schedule and set your own schedule in ZenCache → Plugin Options → Manual Cache Clearing → Cache Cleanup Schedule. ZenCache uses wp_get_schedules() when generating the list of available schedules, which makes it possible to create your own custom cron schedule using a plugin like WP Crontrol and use that to define a custom Cache Cleanup Schedule. Props @kristineds. See Issue #472.
@raamdev raamdev closed this Nov 20, 2015
@wpsharks wpsharks locked and limited conversation to collaborators Dec 21, 2015
@raamdev
Copy link
Contributor

@raamdev raamdev commented Dec 21, 2015

ZenCache Pro v151220 has been released and includes changes worked on as part of this GitHub Issue. See the release 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 (#472).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants