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?
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"...
Check expires header in YSlow:
Possibly works another location. Try same config:
After change config, reload nginx:
The issue is that favicon.ico is not matched in the condition you have specified. Try adding something like this.
Some clients look for the favicon in the root of your site.