加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

在我的页面的一部分与Php“无缓存”的方法?

发布时间:2020-12-13 16:47:28 所属栏目:PHP教程 来源:网络整理
导读:我的网站页面上有一个表单.我有一个表格,提交表单中的回声,我想不缓存,因为当你输入表单时,缓存版本显示,而不是更新.有没有更好的方法来不缓存页面而不是元标记? 我现在使用的代码是 ?php $query='select * from article order by `article`.`time` DESC LI
我的网站页面上有一个表单.我有一个表格,提交表单中的回声,我想不缓存,因为当你输入表单时,缓存版本显示,而不是更新.有没有更好的方法来不缓存页面而不是元标记?

我现在使用的代码是

<?php
       $query='select * from article order by `article`.`time` DESC LIMIT 10';
       $result=mysql_query($query); 
       echo '<table class="mytable" width="1000px" border="0">';
       while($row = mysql_fetch_array($result))
       {
    echo "<td><a href='".$row['url']."'>".$row['title']."</a> - ".$row['name']."</td><td>".$row['class']."</td></tr>";
}
echo '<table>';
       ?>

解决方法

<?php
header("Cache-Control: no-cache,must-revalidate"); // HTTP/1.1
header("Expires: Sat,26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

见http://php.net/manual/en/function.header.php

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读