防止缓存 HTML 页面 [英] Prevent caching of HTML page

查看:24
本文介绍了防止缓存 HTML 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 HTML 页面.问题是我不想让用户每次添加新内容时都刷新页面.

I have a HTML page. The problem is that I do not want to have the users to refresh the page each time I put on new content.

为了确保页面不被缓存,我有以下代码:

I have the following code in order to make sure that the page is not cached:

     <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
     <meta http-equiv="Pragma" content="no-cache"/>
     <meta http-equiv="Expires" content="0"/>

问题是,我仍然需要刷新页面才能显示最新的内容.难道我做错了什么?我应该使用其他标签吗?

The problem is, I still need to do a refresh on the page in order to get the most current content to show up. Am I doing something wrong? Should I be using some other tags?

推荐答案

你的值没问题,但是 meta http-equiv 非常不可靠.您应该使用真正的 HTTP 标头(具体如何操作取决于您的服务器,例如 对于 Apache).

The values you have there are OK, but meta http-equiv is highly unreliable. You should be using real HTTP headers (the specifics of how you do this will depend on your server, e.g. for Apache).

这篇关于防止缓存 HTML 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆