• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Caching, expire, compressing on only Nginx

Dukemaster

Regular Pleskian
Hi @ . all,
sorry to come again with the same old story. If there is the an actual solution here in community, I would be also happy and thankful if you could point me to it. Because here is so much with different configuration.
Using apache with Nginx as proxy, others without proxy.
If someone knows the best way to configure caching, expire and compression for only nginx configuration would be great.


Greets

Plesk - Plesk Only Config-1.jpg
 
Last edited:
Hello!,

I am using this code at nginx additional directives.

Code:
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json application/x-font-ttf application/x-font-opentype image/svg+xml;
gzip_vary on;

location ~* \.(?:ico|gif|jpe?g|png)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
}
location ~* \.(?:css|js)$ {
    expires 7d;
    add_header Pragma public;
    add_header Cache-Control "public";
}

Gzip part is for compression.
Locations part are for caching static resources.

This woked for me at Google Page Speed Insights, I am using it on Wordpress site with apache and nginx as reverse proxy. Remember to uncheck "serve static resources from nginx" option, and include all mime-types or extensions you want to cache on nginx additional directives.

Hope this helps!.
 
Back
Top