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

Feature request: Release previous caching jobs before generating cache #454

Closed
jorisnoo opened this issue Nov 21, 2022 · 6 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@jorisnoo
Copy link

Hi, - and first of all, thank you very much for all your effort on this great plugin!

i'm using blitz on a site with a few thousand pages, so generating the full cache is taking some to finish.
This is generally no issue, except in some cases:

  1. on each deployment, the cache is flushed and newly generated. if there are, however, a few consecutive deployments, they result in multiple (possibly overlapping) jobs in the queue that generate the cache. some of them usually tend to time out and fail
  2. when editors make a lot of changes to the site, the same appears to happen: the queue is piling up with blitz jobs — which end up blocking other jobs in the queue from running

i was therefore wondering, whether it'd somehow be possible to release all blitz jobs from the queue before starting to (re-)generate the cache; or if there was any other way to prevent this from happening?

Thank you very much for your help!

Craft CMS Pro 4.3.1
Blitz 4.2.3

@jorisnoo jorisnoo added the enhancement New feature or request label Nov 21, 2022
@jorisnoo jorisnoo changed the title Fature request: Release previous caching jobs before generating cache Feature request: Release previous caching jobs before generating cache Nov 21, 2022
@bencroker
Copy link
Collaborator

bencroker commented Nov 21, 2022

When you say "deployment", what kind of setup are you referring to?

What you're asking is not as trivial as it sounds, because saving an entry can affect pages which may be different to the pages changed by saving another entry. If we're talking about generating the entire cache then you may have a point, I'll need to look into it further though, as there are lots of pieces to this puzzle and some things have to happen in a certain order.

@jorisnoo
Copy link
Author

@bencroker Thanks for your prompt response!

Sorry, by "deployment" i meant deploying updates of the codebase to the staging or production server. Eg. when twig templates are changed and those changes are deplyoed to the server, the whole blitz cache is cleared.

I see your point. For my case, it'd already be very helpful, if running php craft blitz/cache/refresh --queue=1 from the console would first release all running blitz jobs (since the entire cache is rebuilt, correct?). Or exposing another console command to clear all blitz jobs, that could be run before that one, would also work just as well. Is this something you'd consider looking into? Many thanks!

@bencroker
Copy link
Collaborator

Yeah I can look into which approach makes the most sense, thanks for the suggestion!

@bencroker bencroker self-assigned this Nov 22, 2022
@bencroker
Copy link
Collaborator

Added in 8d179d1 for the next release. Note that this will only work when cache clearing is enabled, as otherwise the cache generation jobs need to be allowed to complete, since they are responsible for regenerating expired cache.

@jorisnoo
Copy link
Author

jorisnoo commented Dec 5, 2022

Thank you! 🙌

@bencroker
Copy link
Collaborator

Just released in version 4.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants