Reputation: 1603
I'm trying to cache .css e .js files.
At the moment in this way is not working:
location /static {
alias /var/www/ttch/assets/;
}
location ~* ^.+\.(css|js)$ {
access_log off;
expires max;
}
With only this config, nginx serve correctly static file without cache:
location /static {
alias /var/www/ttch/assets/;
}
Any hints about how can I merge this two directives? Thanks.
Upvotes: 2
Views: 1573
Reputation: 15530
Alias or root directive helps you to identify location on the file system, but location is self-contained block you can extend easily, so this will work properly:
location /static {
alias /var/www/ttch/assets/;
access_log off;
expires max;
}
If you want to serve files with particular extensions, try this one:
location ~ ^/static/(.+\.(?:css|js))$ {
alias /var/www/ttch/assets/;
access_log off;
expires max;
}
Upvotes: 2