-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Command for clearing old/stale http_cache (Symfony Reverse Proxy) entries #40548
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
Comments
Extending |
So, the only way is to add brand new command? I'm fine with it. |
perhaps related to #40218 if we do use a pool :) why not?
see also https://github.com/Toflar/psr6-symfony-http-cache-store |
Nice, thanks. IMO new command would be best fit to just clear stale entries. It won't touch |
i forgot to mention, but FOSHttpCache provides the command we're looking for: it's the more general approach, as it's store based ; not pool based per se. however, i still think being able to configure "store as a service" for CacheKernel is nice, and with existing IIUC FrameworkBundle can then mark a public alias (eg. AFAIK we should avoid hitting the backend, not hitting the container per se. Correct me if im wrong tho. |
If I understand correctly it is invalidating not pruning (clearing) stale entries? Also FOSHttpCache is separate bundle, what about uses who just wants |
Right, we cannot prune by tag neither with SF cache pools nor with FOSHttpCache. Is that common though? (eg. compared to pruning everything)
I think it's reasonable to have the https://github.com/Toflar/psr6-symfony-http-cache-store/blob/main/src/Psr6StoreInterface.php contract in core, if only for a leaser amount of deps. The tricky part is to actually tag cache entries from eg. the response headers, and this area is exactly solved by FOSHttpCache. So given your store is PSR6 based, you should be able to leverage |
For me, it will be easier to just add command to prune entries in Adding PSR6 to CacheKernel means refactor and/or rewrite some part of CacheKernel's storage system and then adding command to prune entries. Fabien's comment for "PSR6 Store for HttpCache" PR: #20061 (comment)
WDYT? |
using filesystem is an implementation detail to me. AFAIK we do have access to the container :) |
According to https://github.com/symfony/symfony/blob/5.x/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php#L78 decorated Kernel is booted only on "forward". Does trying to have DI container means booting kernel even with cache hit? For me it looks like performance degradation, I know we now have Preloading, OPCache and even JIT compiler, but not running code is faster than running code :) |
i assume a cached compiled container yes :) i dont have numbers, so im not sure how bad the degradation would be. |
Sure thing, production-ready container, but still code needs to be run :) Why would you like to make HttpCache's store PSR6 compatible? |
because FOSHttpCache requires it 😅 https://github.com/FriendsOfSymfony/FOSHttpCache/blob/master/src/CacheInvalidator.php#L111 and the framework's semantic config for cache pools is 👌 |
On the other hand, one small command will resolve my issue (and others too, I bet :) ). Is there any problem with command dedicated to pruning HttpCache's storage (and storage is also dedicated)? |
im not sure creating CLI infra around stores is worth the effort, given we have infra for pools already. i agree a simple command in your app may be sufficient. |
Well isn't it as simple as Or maybe more advanced to remove only files older than 1 day: |
in our case we cant afford it. Must be done by tag :) also to me rm -rf is just spartan. |
@dmaicher The idea is to just prune stale entries, some may have 1 day TTL, others 1 month TTL. |
Thank you for this suggestion. |
In the end I used, proposed earlier, https://github.com/Toflar/psr6-symfony-http-cache-store and it works. IMO it will nice addition to Symfony but my issue was resolved, so this ticket can be closed. |
Description
Hello, I'm using Symfony's HTTP Cache functionality (https://symfony.com/doc/current/http_cache.html), my app is not big, but this cache generates about 50MB (and growing) in entries - I would like to reduce this number. One way is to remove whole directory, but this also removes valid entries. There is a
bin/console cache:pool:prune
command, but it doesn't clearhttp_cache
directory.What I'm suggesting here is to extend command
cache:pool:prune
to also prunehttp_cache
entries or add brand new command, for examplehttp-cache:prune
- of course i can provide PR.WDYT?
The text was updated successfully, but these errors were encountered: