skip to Main Content

I’m running a Joomla site running on a Plesk VPS with Apache + nginx. In the “Web Server Settings” in Plesk for that domain under “Additional nginx directives” (which will override the server-wide nginx configuration) I have specified:

add_header Cache-Control "private, max-age=604800, must-revalidate";

All works well and the site now gets served with proper cache headers added and Google PageSpeed stopped complaining – but I’m getting some errors with back-end functions now such as when uploading batches of images to my website’s gallery. This seems to be related to the above as it works normally again when the directive is removed.

How can I re-write the additional nginx directive above to exclude the /administrator/ directory of my site from having any cache headers added by nginx?

2

Answers


  1. Use a location block that negates the path you don’t want the header added to:

    location ^~ /administrator/ {
        add_header Cache-Control "private, max-age=604800, must-revalidate";
    }
    
    Login or Signup to reply.
  2. If you have nginx+apache:

    add_header Cache-Control "private, max-age=604800, must-revalidate";
    
    location ^~ /administrator/ {
            add_header Cache-Control "no-cache, max-age=1";
            proxy_pass http://[....IP address of domain ....]:7080;
            proxy_set_header Host             $host;
            proxy_set_header X-Real-IP        $remote_addr;
            proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
    
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search