문제

I have an nginx setup with multiple server blocks. I'd like to know if there's a way to globally set the value of expires to max for all images, CSS and JS across the server.

I know I can use this:

location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
   expires max;
}

But then I'd have to add it to every server block, since location isn't allowed in http.

Is there a way to set expires to max for specific mime-types or extensions, globally?

도움이 되었습니까?

해결책

Try it first cause I haven't tested this before.

conf file /etc/nginx/img-cache.conf for example

location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires max;
}

server

server {
    #bla bla
    include /etc/nginx/img-cache.conf;
    #bla bla
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top