最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin10PV0评论

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far