doumao1047 2015-07-09 09:51
浏览 49

目标特定文件 - NO-CACHE PHP

I'm using the following code to prevent a page from caching a twig random() command.

<?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. default.html ? Instead of preventing caching for the entire site?

  • 写回答

1条回答 默认 最新

  • dongxuan2577 2015-07-09 09:57
    关注

    You should disable the caching on the Response object for that specific page:

    $response->setPrivate()
    

    Also see the API documentation: http://api.symfony.com/master/Symfony/Component/HttpFoundation/Response.html#method_setPrivate

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料