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.
Using
curl
: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.