4

I have set Cache-Control in apache for 1 week for my JS Files but when i check in the browser Cache-Control shows no-cache. Where i am missing the configuration ?

Below is my configuration in apache

<ifModule mod_headers.c>

  <filesMatch "\.(html|htm|png|js|css)$">
   Header set Cache-Control "max-age=604800, public"
  </filesMatch>

</ifModule>

Request Header in Browser

    Request URL:http://test.com/Script.js?buildInfo=1.1.200
    Request Method:GET
    Status Code:200 OK
    Request Headersview source
    Accept:*/*
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-US,en;q=0.8
    **Cache-Control:no-cache**
    Connection:keep-alive
    Host:test.com
    Pragma:no-cache
    Referer:http://test.com/home.jsp
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like      
    Gecko) Chrome/37.0.2062.120 Safari/537.36
    Query String Parametersview sourceview URL encoded
    buildInfo:1.1.200

    Response Headersview source
    Cache-Control:max-age=2592000
    Connection:keep-alive
    Content-Encoding:gzip
    Content-Type:text/javascript
    Date:Sun, 12 Oct 2014 16:17:46 GMT
    Expires:Tue, 11 Nov 2014 16:17:46 GMT
    Last-Modified:Tue, 07 Oct 2014 13:28:08 GMT
    Server:Apache
    Transfer-Encoding:chunked
    Vary:Accept-Encoding

2 Answers 2

0

You need to enable the headers module, assuming debian:

sudo a2enmod headers

then for changes to take effect, you must reload or restart apache:

sudo service apache2 reload

If this does not have an effect, there is also several other parts of your configuration that may override the Cache-Control directive, for example in a .htaccess served from your web root.

Also, I am not sure if Apache allows any capitalisation in your server configuration. Possibly you must use (notice the capital I) and if apache does not recognize your capitalisation, it should print errors when being restarted.

0

Cache-Control:no-cache does not appear alone, it is being produced by the application.

Whether something is configured in Apache or not, whatever the application returns will override the defaults.

So the besides @MartinOlika answer, the application will have to be reviewed, or if you whish, the desired configuration can be done at application level.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.