I am using apache tomcat server and have a web application rendering several js,css and image files. I want to make sure that these files are cached by the browser so that they are not requested each time. However, I noticed that some files are getting cached while others are not. I found out that the response header from the app has Expires : "Dec 31 1969 at 7:00 PM". After going through this I removed the tomcat security-constraint from the web.xml which removed the header successfully. I also configured the Expires header in my app to 1 week from present. That too didn't make sure that the pages are cached.
Following this I configured the Cache-Control header to public with max-age set to 1 week. None of these changes are helping me. Moreover, the pages getting cached and not getting cached have the same headers as below:
HTTP/1.1 200 OK
Cache-Control: max-age=604800, public
ETag: 240983
Last-Modified: Fri, 09 Sep 2016 18:49:42 GMT
Date: Wed, 01 Feb 2017 07:34:25 GMT
via: HTTP/1.1 ab-d-klt-tom1
Expires: Wed, 08 Feb 2017 07:35:29 GMT
Content-Type: application/x-javascript
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
X-FRAME-OPTIONS: SAMEORIGIN
X-Powered-By: Servlet/3.0
X-UA-Compatible: IE=edge
Server: Apache
Apart from this I have also tried the ExpiresFilter as described here without any luck.
EDIT : My application when deployed in a windows environment with Tomcat and no SSL is successfully caching all the files in the browser.
However, when the app is deployed in a Linux environment with Tomcat and SSL is not caching files. Is SSL causing this?
You need to get rid of SSL certificate error. Chrome does not cache resources with such errors.
For more information check Chromium issues below: