Friday 15 July 2011

optimization - nginx: try to serve minified files first -


I am trying to optimize my website by reducing CSS, JS, SVG and Whitenet.

Although it interferes with my codebase and I want to keep the original files all around I have any css | Js | Svg to min.css | Min.js | Git is set to min.svg to self-verbally, but I have every php or HTML file which is .min links to these files to use extensions.

To improve it, I was thinking that I can set nginx automatically serves the minimum versions of files when request for non-mined files try_files Using instructions and using non-micrified files as backups, if they are not present.

This is what I mean to extend some pseudo-configurations:

  location. (CSS | JS | SVG) {try_files $ minified_uri $ uri; }   

But I have no indication how to get $ minified_uri here (like /some/style.min.css /some/style.css is requested when it is served).

In addition, if you think that this approach is really bad, please tell me why show me some more options!

It is quite easy to use the regex variable:

  Place ~ ^ (. +) \. (CSS | JS | SVG) $ {try_files $ 1.min $ 2 $ uri = 404; }    

No comments:

Post a Comment