skip to Main Content

I needed to set Cache-Control to be enabled for mobile caching in an app.

Problem was no matter what I put in the .htaccess the response header did not change. It stayed as

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0

I tried disabling nginx in plesk and the result was the following:

Cache-Control:max-age=2628000, public
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0

the .htaccess code that I put in there:

 Header set Cache-Control "max-age=2628000, public"

2

Answers


  1. Chosen as BEST ANSWER

    The problem here is that the CMS I used (Processwire) set Cache-Control to no cache automatically.

    I simply added

    header_remove("Cache-Control");
    

    on pages I want Cache-Control to fully follow my .htaccess


  2. You have two “Cache-Control” headers in response:

    Cache-Control:max-age=2628000, public
    Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    

    It means that you have second definition of “Cache-Control” header , it can be in global apache configs, in VirtualServer of your domain, in another .htaccess.

    /etc/httpd/ or /etc/apache2/ <-- for global configs
    /var/www/vhosts/system/your-domain.tld/conf/ <-- for custom configs
    /var/www/vhosts/your-domain.tld/ <-- for another .htaccess files
    

    Also back-end application(PHP) and front-end(JavaScript) can add this header.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search