Welcome! Log In Create A New Profile

Advanced

Re: How can i write this location?

Maxim Dounin
September 08, 2009 10:00AM
Hello!

On Tue, Sep 08, 2009 at 06:08:01PM +0800, Chancey wrote:

> Hi guys!
>
> How to set expires the URL like http://a.com/a.js?v=xxx and http://a.com/a.css?v=xxx.
> only match URL with "?v="
>
> i write this, but can't invalidation :
>
> location ~* \.(js|css)\?v=.* {
> expires 1y;
> }

Location directives doesn't match query string, you have to
use "if" to check for "v" argument.

Something like this should work:

location ~* \.(js|css)$ {
if ($arg_v) {
expires 1y;
}

# no expires for requests without v= argument
}

Note that generally "if" is evil (search mailing list archive for
details) and it's use is discouraged. In this particular case
it should be safe enough, but expanding the above configuration
may introduce problems.

Maxim Dounin
Subject Author Posted

How can i write this location?

Chancey September 08, 2009 06:10AM

Re: How can i write this location?

Maxim Dounin September 08, 2009 10:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 258
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready