Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

here is my conf file: usr/local/nginx/sites-available/default

server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
# redirect server error pages to the static page /50x.html

error_page 500 502 503 504 /50x.html;
location = /50x.html
root html;
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|swf)$ {
expires 30d;

but it doesn't cache static files, how should I fix it? thanks a lot

share|improve this question

This works for me:

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
            root   /var/www/u_1/public_html/;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.