How to cache js/css request containing a question mark?

log nginx-forum at nginx.us
Mon Aug 31 15:59:40 UTC 2015


Following nginx configuration in a server block can cache js and css files
with "js" or "css" as the end of the url.

        location ~ .*\.(js|css)?$ {
                expires 7d;
                }

But it can't cache request such as:

http: //example.com/jquery.js?ver=1.11.3&build=1

or

http: //example.com/style.css?ver=4.3&build=1

Any way to cache cs/jss files above? Or cache files based on the file type
of request instead of file name?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,261338,261338#msg-261338



More information about the nginx mailing list