1

I have configured Nginx (on my local server) to add Expires headers like this:

location ~* \.(ico|css|js|gif|jpe?g|png)$ {
    expires max;
    #auth_basic "Restricted, please login";
    #auth_basic_user_file htpasswd.users;
}

But YSlow keeps on saying:

There is 1 static component without a far-future expiration date.
* (no expires) http://atpc.dev/f/a/i/favicon.ico

Am I doing something wrong?

  • It's most likely just a browser cache, Nginx is sending the proper headers. – Martin Fjordvald Feb 18 '11 at 0:18
2

After many tests, I noticed that my original regex was working fine since the beggining. However, the .ico file was wrongly named so the browser was not finding it. This was the true cause of YSlow alert. Of course, a file not found should not show a "far-future expiration date" alert but a "content not found"...

1

Check expires header in YSlow: PrtSc

Possibly works another location. Try same config:

location = /f/a/i/favicon.ico {
    expires max;
}

After change config, reload nginx:

$ sudo nginx -t
$ sudo nginx -s reload
  • This is just what is happening with me. The other files (css, js, jpg, gif, pńg) are fine. – Roger Feb 18 '11 at 0:06
  • Still not working... There is 1 static component without a far-future expiration date. * (no expires) atpc.dev/f/a/i/favicon.ico – Roger Feb 18 '11 at 0:40
0

The issue is that favicon.ico is not matched in the condition you have specified. Try adding something like this.

location /favicon.ico {
          expires max;      
}
  • Really? what about this part of the regex: \.(ico wouldn't this get files like *.ico ? – Roger Jun 1 '11 at 11:22
0

Some clients look for the favicon in the root of your site.

location /favicon.ico {
    # if not found send 204 (content not found)
    try_files /f/a/i/favicon.ico =204;  
    expires max;      
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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