Setting expires headers for static content served from nginx

I prefer to do a more complete cache header, in addition to some more file extensions. The ‘?’ prefix is a ‘non-capturing’ mark, nginx won’t create a $1. It helps to reduce unnecessary load.

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

Leave a Comment