[英]Target Specific File - NO-CACHE PHP
I'm using the following code to prevent a page from caching a twig random()
command. 我正在使用以下代码来防止页面缓存嫩枝random()
命令。
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
?>
I am only using the random()
command on a single page, but the file that controls caching is global, is there away to target a specific file ie. 我只在单个页面上使用random()
命令,但是控制缓存的文件是全局文件,因此可以定位到特定文件,即。 default.html
? default.html
吗? Instead of preventing caching for the entire site? 而不是阻止整个站点的缓存?
You should disable the caching on the Response object for that specific page: 您应该为该特定页面禁用Response对象上的缓存:
$response->setPrivate()
Also see the API documentation: http://api.symfony.com/master/Symfony/Component/HttpFoundation/Response.html#method_setPrivate 另请参阅API文档: http : //api.symfony.com/master/Symfony/Component/HttpFoundation/Response.html#method_setPrivate
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.