javascript - how to verify "Cache-Control", "no-cache, no-store, must-revalidate" - Stack Ov

I am learning about cache and how to manage it.I can see that static content like images, css files, js

I am learning about cache and how to manage it.

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.

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.

So am I doing something wrong.

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.

After these changes :

Response Headers

     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

Before these changes:

Response Headers

    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.

I am learning about cache and how to manage it.

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.

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.

So am I doing something wrong.

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.

After these changes :

Response Headers

     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

Before these changes:

Response Headers

    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.

Share Improve this question asked Dec 12, 2014 at 13:34 OnkiOnki 2,0957 gold badges40 silver badges68 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

Using curl:

curl -I  "URL"

The -I flag will show the headers.

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745603212a4635524.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信