简体   繁体   中英

Delete a cached file with a spesific Uri in symfony2

When I use HTTP cache for a custom page, Symfony2 creates a file for it under the cache folder and it's possible to set timeout for this cache. But when I update some of my database information that is related to that particular page my users are unable to see changes (depending on the cache life time). In order to solve this problem I want to delete a specific file in update action with the URI of that page. In symfony book said:"The most standard way is to purge the cache for a given URL by requesting it with the special PURGE HTTP method". but how can I create a PURGE HTTP method from inside of my symfony controller? Is it possible? or there is another way?

The built in reverse proxy cache probably isn't the best place to do this sort of caching. This cache is best used as described - don't use it to store things that need to be invalidated manually, it will save you a lot of headaches.

If the database lookup your are doing is heavy then look at using the doctrine result cache , or implement a cache in-between doctrine and your response using one of the exisiting cache bundles

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM