【问题标题】:Prevent page caching and avoid redirect防止页面缓存并避免重定向
【发布时间】:2015-10-30 14:06:59
【问题描述】:

我的网站是用 PHP 编写的,我使用重定向来防止页面缓存。也就是说,当用户打开page.php?page=info 时,他被重定向(302)到page.php?page=info&timestamp=20151030120000。但这有时会变慢,而且我担心像谷歌或雅虎这样的网络爬虫不喜欢这样。 SSL 有点太贵了,而且 META 标签似乎完全没有效果。还可以做些什么来防止缓存?谢谢!

【问题讨论】:

  • 为什么meta标签好像失效了??

标签: php browser-cache


【解决方案1】:

如果你想通过meta标签试试,试试这个:

<meta http-equiv="expires" content="Mon, 03 Jun 2015 00:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache" />

或直接在页面上:

<?php

  header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
  header("Cache-Control: post-check=0, pre-check=0", false);
  header("Pragma: no-cache");

?>

【讨论】:

  • 谢谢,我试试这个!
  • 好东西。很高兴为您提供帮助
猜你喜欢
  • 2012-02-19
  • 2013-05-18
  • 2020-05-27
  • 1970-01-01
  • 2016-05-07
  • 2013-03-12
  • 1970-01-01
  • 2018-02-03
相关资源
最近更新 更多