Welcome! Log In Create A New Profile

Advanced

Rewrite statics

Posted by illarra 
Rewrite statics
June 08, 2010 07:18AM
I want to read the static files of my website using this kind of URLs:

[i]{filename}.{timestamp}.{extension}[/i]
ex. [b]jquery.1234567890.js[/b]

The idea is to control what version of the file is being cached by the browser.

Then when I ask nginx to serve the file, I would like to serve directly the [b]jquery.js[/b] file.
So I'm dealing with some kind of rewrite.

I know where I have to put it, but not how...
[code]
server {
...
location ~* ^.+\.(css|gif|jpg|js|png|swf)$ {
[b]rewrite rule goes here[/b];
root /home/web/statics/;
expires 90d;
add_header Cache-Control public;
}
}
[/code]

Thanks for the help.



Edited 1 time(s). Last edit at 06/08/2010 07:19AM by illarra.
Re: Rewrite statics
June 08, 2010 07:36AM
Well... I found this:
http://particletree.com/notebook/automatically-version-your-css-and-javascript-files/

So I changed the code to:
[code]
...
location ~* ^.+\.(css|gif|jpg|js|png|swf)$ {
rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
root /home/web/statics/;
expires max;
add_header Cache-Control public;
}
...
[/code]
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 178
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready