Search code examples
.htaccesscachingnginxplesk

Setting Cache-Control header in plesk results in contradiction


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"

Solution

  • 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.