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?

Ben Pilbrow
  • 11,995
  • 5
  • 35
  • 57
Roger
  • 473
  • 11
  • 22

4 Answers4

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

Roger
  • 473
  • 11
  • 22
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
ooshro
  • 10,874
  • 1
  • 31
  • 31
  • This is just what is happening with me. The other files (css, js, jpg, gif, pńg) are fine. – Roger Feb 18 '11 at 00:06
  • Still not working... There is 1 static component without a far-future expiration date. * (no expires) http://atpc.dev/f/a/i/favicon.ico – Roger Feb 18 '11 at 00: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;      
}
Sameer
  • 4,070
  • 2
  • 16
  • 11
  • Really? what about this part of the regex: `\.(ico` wouldn't this get files like *.ico ? – Roger Jun 01 '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;      
}
Dario
  • 1
  • 1