• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Expire Cache Header in Additional Nginx Directives not Working

einstein

New Pleskian
hi,

newbie to Plesk.
My current server config.
Nginx as webserver. No apache.

Smart static files processing >> ON (apparently when i off it, my web doesnt work)
Serve static files directly by nginx >> OFF (tried with ON, and removing the extensions like css/jpg but it still doesnt work)

im using this cache expiry header in my additonal nginx directives
Code:
# Expire rules for static content

# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}

# Feed
location ~* \.(?:rss|atom)$ {
expires 1h;
add_header Cache-Control "public";
}

# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}

# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}

# WebFonts
# If you are NOT using cross-domain-fonts.conf, uncomment the following directive
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
expires 1M;
access_log off;
add_header Cache-Control “public”;
}

nothing works!

any help? i have scoured the forums up and down, seems like there are others who are experiencing the same thing as me.

i thought expire header should be something that is implemented long time ago?
 
There are several threads about this topic and there is no solution yet.
It was working fine in plesk 12.
 
@einstein,

It is quite easy.

I stumbled on your post, because I thought that you used the settings that I provided (somewhere on this forum), which resulted in the big question: "why? it DOES work"

Well, after staring a bit at your directives, I noticed something that should be removed: the "?:" part.

For instance, the line

location ~* \.(?:css|js)$


becomes

location ~* \.(css|js)$


and that should do the trick, note that you have to apply the edit to all other lines containing the "?:".

That´s all, just try it.

Regards.....
 
@trialotto

thank you for the reply.

i tried this new code:
Code:
# Expire rules for static content

# cache.appcache, your document html and data
location ~* \.(manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}

# Feed
location ~* \.(rss|atom)$ {
expires 1h;
add_header Cache-Control "public";
}

# Media: images, icons, video, audio, HTC
location ~* \.(jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}

# CSS and Javascript
location ~* \.(css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}

# WebFonts
# If you are NOT using cross-domain-fonts.conf, uncomment the following directive
location ~* \.(ttf|ttc|otf|eot|woff|woff2)$ {
expires 1M;
access_log off;
add_header Cache-Control “public”;
}

still get the same response:
Code:
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 15 Apr 2016 03:49:41 GMT
Content-Type: image/jpeg
Content-Length: 377332
Last-Modified: Wed, 30 Mar 2016 06:24:47 GMT
Connection: keep-alive
ETag: "56fb712f-5c1f4"
Accept-Ranges: bytes

what i did wrong?
 
@trialotto i tried restarting the server, didnt work for me as well.

i did try this command to check for expiry header.
Code:
curl -X GET -I domain.com/file-name.jpg/css/js

didnt say that i have expiry header set.
 
@einstein,

Just use Mozilla (and press CTRL + F5) to reload a request with a clean browser cache.

Also note that your URL in the curl request is probably not pointing to any file.

Regards....
 
@einstein,

I would suggest that you send me a PM (start a conversation with me) and give me the URLs of the troublesome domains, so I can check myself.

Regards....
 
@trialotto thank you for the offer. i have submit a support ticket to plesk. and they have been poking around in my server for like 24 hours already, and couldnt find the solution. :S

will update here soon.
 
@einstein

That does not surprise me: there is nothing wrong with the Nginx customization, as far as I can see.

And I explicitly mention "as far as I can see", because not having the URLs or other information, does not allow me to do a proper check.

Anyway, the latter does not matter.......you are simply losing time, because of something (i.e. Nginx customization) that already is done properly.

Regards...
 
hi again @trialotto plesk have spent like almost a week on my server finding the root cause.

and they said that it's because im using nginx as webserver only.

are you using apache with nginx as reverse proxy? or same as me.

anyway, i will drop you a pm to see if anything is wrong with my site.

thank you in advance
 
Back
Top