简体   繁体   English

在symfony2中删除带有特殊Uri的缓存文件

[英]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. 当我将HTTP缓存用于自定义页面时,Symfony2会在缓存文件夹下为其创建文件,并且可以为此缓存设置超时。 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. 为了解决此问题,我想使用该页面的URI在更新操作中删除特定文件。 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". 在symfony书中说:“最标准的方法是通过使用特殊的PURGE HTTP方法请求给定URL来清除高速缓存”。 but how can I create a PURGE HTTP method from inside of my symfony controller? 但是如何在symfony控制器内部创建PURGE HTTP方法? 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 如果您正在执行的数据库查找比较繁琐,则可以使用该方法结果缓存进行查看,或者使用现有的缓存捆绑之一在该方法和您的响应之间实现一个缓存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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