Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

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)

Am I doing something wrong?

share|improve this question
It's most likely just a browser cache, Nginx is sending the proper headers. – Martin Fjordvald Feb 18 '11 at 0:18
up vote 2 down vote accepted

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"...

share|improve this answer

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
share|improve this answer
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) – Roger Feb 18 '11 at 0:40

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;      
share|improve this answer
Really? what about this part of the regex: \.(ico wouldn't this get files like *.ico ? – Roger Jun 1 '11 at 11:22

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;      
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.