can't get cache controle to set an expire date

Maxim Dounin mdounin at mdounin.ru
Fri Sep 16 10:19:51 UTC 2011


Hello!

On Fri, Sep 16, 2011 at 11:49:34AM +0200, Mahalingam Mr wrote:

> #   location /images/ {
> #       # serve from disk and set expires
> #       expires max;
> #   }
> #
> #   location /stylesheets/ {
> #       expires max;
> #   }
> #
> #   location /javascripts/ {
> #       expires max;
> #   }
> 
> 
> Solution:
> 
> Try this instead of giving the folders explicitly.,

No, this is bad idea.  Using regexp locations is bad as it makes 
configuration support much harder.  Using separate prefixes for 
static files is much more scalable aproach.

Additionally, this particular snippet is incorrect and misleading 
in serveral ways.

> location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {

Testing "\?..." is meaningless: query string isn't tested by 
"location" directives.

>        expires max;
>        break;

Directive "break" here does nothing but wastes cpu cycles.

>     }

Maxim Dounin



More information about the nginx mailing list