如何验证“高速缓存控制”,“无高速缓存,无存储,必须重新生效” [英] how to verify "Cache-Control", "no-cache, no-store, must-revalidate"

查看:152
本文介绍了如何验证“高速缓存控制”,“无高速缓存,无存储,必须重新生效”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在了解缓存以及如何管理它。

I am learning about cache and how to manage it.

我可以看到静态内容,如图片,css文件,js文件存储在临时文件夹打开我的网页。但是现在当我在响应头中添加这些属性时,我看不到缓存行为的任何更改。

I can see that static content like images, css files, js files gets stored in temporary folder when I open my website pages. But now when I added these attributes in response header, I cannot see any changes in cache behaviour.

所有内容都像以前一样存储。即使我在js文件中进行一些更改,我看不到新的js文件被抓取。浏览器使用的旧js文件包含过期的内容。

All content is getting stored like before. And even when I am making some changes in js files, I cannot see new js files being fetched. Browser uses the same old js files with outdated content.

所以我做错了。

我在JSP档案中新增的逻辑:

Logic that I added in JSP file :

    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP1.1.

    response.setDateHeader("Expires", 0); // Proxies.

  response.setHeader("Pragma", "no-cache"); // HTTP 1.0.

执行以下更改后:

响应标头

     Cache-Control:no-cache, no-store, must-revalidate

    Content-Language:en-US

    Content-Length:3333

    Content-Type:text/html;charset=ISO-8859-1

    Date:Fri, 12 Dec 2014 11:48:37 GMT

    Expires:Thu, 01 Jan 1970 00:00:00 GMT

    Pragma:no-cache

    Server:WebSphere Application Server/8.0

    X-Powered-By:Servlet/3.0


b $ b

在这些更改之前:

Before these changes:

响应标题

    Content-Language:en-US

    Content-Length:6788

    Content-Type:text/html;charset=ISO-8859-1

    Date:Fri, 12 Dec 2014 11:50:10 GMT

    Server:WebSphere Application Server/8.0

    X-Powered-By:Servlet/3.0

我只想知道如何验证这些标头是否正常工作。

I just wanted to know that how can I verify that these headers are working properly. Any help would be appreciated.

推荐答案

在Chrome中安装LiveHTTPHeaders,您可以看到页面中的所有标题。你也可以用硬盘的方式做,并使用pcap工具,如tcpdump或Wireshark查看请求的数据包和查看头。

Install LiveHTTPHeaders in Chrome and you can see all the headers in the page. You can also do it the hard way and use a pcap tool like tcpdump or Wireshark to see the requested packets and view the headers.

这篇关于如何验证“高速缓存控制”,“无高速缓存,无存储,必须重新生效”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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