Expire headers on nginx

gldtn

Well-known member
Hello,

May someone help with expire headers on nginx?

Here is my setup:
NGINX:
# Expires map
    map $sent_http_content_type $expires {
    default                    off;
    text/html                  epoch;
    text/css                   max;
    text/javascript            max;
    text/x-javascript          max;
    text/plain                 max;
    text/xml                   max;
    application/atom+xml       max;
    application/geo+json       max;
    application/javascript     max;
    application/x-javascript   max;    
    application/json           max;
    application/ld+json        max;
    application/manifest+json  max;    
    application/rdf+xml        max;
    application/rss+xml        max;
    application/xhtml+xml      max;  
    application/xml            max;
    ~font/                     max;
    ~image/                    max;
}

Server block:
NGINX:
expires $expires;

But I still get a "C" over at https://tools.pingdom.com/

I know it's working because before I was getting an F, any suggestion on what I actually need and don't need? Also I'm not sure if it's a good idea to set everything to max like I did.

I followed this guide here: https://www.digitalocean.com/commun...ng-with-nginx-s-header-module-on-ubuntu-20-04

Thanks in advance!
 
Last edited:
Code:
        location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar|ico)$ {
            access_log off;
            log_not_found off;
            expires 30d;
            fastcgi_hide_header "Set-Cookie";
            add_header Pragma "public";
            add_header Cache-Control "public";
        }
 
Top Bottom