I've got an app that runs on a tomcat web server, and I use mod-jk on my apache web server side.
I think I've managed to configure everything to work seamlessly, I ran into issues when I wanted to cache static assets on webserver, for some reason my response headers expires is set to 1994, these are my headers for one of the javascript files I want to server as static asset and cache it:
Accept-Ranges:bytes
Cache-Control:no-cache
Connection:Keep-Alive
Content-Encoding:gzip
Content-Type:application/javascript
Date:Fri, 29 May 2015 23:18:25 GMT
ETag:W/"604348-1432950682000"
Expires:Thu, 01 Dec 1994 16:00:00 GMT
Keep-Alive:timeout=5, max=100
Last-Modified:Fri, 29 May 2015 23:18:25 GMT
Server:Apache
Transfer-Encoding:chunked
Vary:Accept-Encoding
Per the instructions I found on this website I tried to set it inside my virtual host, like in the example below :
<VirtualHost *:80>
Alias /assets /opt/www/tomcat/webapps/ROOT/assets
ServerName dev.myurl.com
ServerAlias anotherone.myurl.com
ErrorLog "|/opt/www/apache/2.2.25/bin/rotatelogs /opt/www/logs/apache/app/_error_log-%Y-%m-%d-%H 86400"
CustomLog "|/opt/www/apache/2.2.25/bin/rotatelogs /opt/www/logs/apache/app/_access_log-%Y-%m-%d-%H 86400" common
JkMount /* workerdev
#--- Disabled Trace -------
RewriteEngine On
RewriteOptions inherit
#----------------------------
ExpiresActive On
ExpiresByType application/x-javascript "now plus 1 months"
</VirtualHost>
This is my first time doing something like this, so I m not sure what else do I need to do, and why is there this default Expires
.
It has been like 9 or 10 hours of different experimenting and none of it worked.
Any suggestions what else could I try?
Update:
It seems like that I'm able to add a http header or but can't override the existing value, by adding this to the VirtualHost
Header unset Cache-Control
Header add Cache-Control "max-age=290304000, public"
Header unset Expires
Header add Expires "Thu, 01 Dec 2015 16:00:00 GMT"
I get this for the response headers :
Cache-Control:no-cache
Cache-Control:max-age=290304000, public
Expires:Thu, 01 Dec 1994 16:00:00 GMT
Expires:Thu, 01 Dec 2015 16:00:00 GMT
Very odd right? Where else could this header values be set from?
Update :
In order to see if the response Expires is being set from the app server I tried following :
Using lynx command line browser to hit the instance directly rather than trough apache
I added the "%{Expires}o" to the tomcat server.xml valve log part, so I can check out the access log, and see what is the expires header returned from the server. After I examined logs, I found that the correct response header is being sent from year 2014, and not the one from 1994.
I modified the mod-jk log level to trace because I wanted to see in which shape does the response arrive back to apache web server. And so in that log I also see that the app server sets the correct Expires response header from 2015 and not from the 1994.
So this pretty much tells me the app server is not setting the Expires
header to 1994
.
Anyone have any opinions what do I do next?