Current time: 12-13-2019, 12:36 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Leverage browser caching of static assets. 1 error.
06-12-2012, 08:10 AM
Post: #1
Leverage browser caching of static assets. 1 error.
Getting this error only on the root part of our domain. (so have a score of 95% for this category)

FAILED - (No max-age or expires) - http://www.mydomain.com/


I am using NGINX. Everything else has a green checkmark. (css file and images) Its just the root domain.

A server admin set it up in the NGINX config file but all i can see related to NGINX is the following:

"proxy_cache_valid 200 2m;

limit_conn_zone $binary_remote_addr zone=lz:10m;
limit_conn lz 60;

limit_req_zone $binary_remote_addr zone=eigth:4m rate=7r/m;
limit_req_zone $binary_remote_addr zone=fourth:4m rate=15r/m;
limit_req_zone $binary_remote_addr zone=half:4m rate=30r/m;
limit_req_zone $binary_remote_addr zone=one:4m rate=1r/s;
limit_req_zone $binary_remote_addr zone=two:4m rate=2r/s;
limit_req_zone $binary_remote_addr zone=three:4m rate=3r/s;
limit_req_zone $binary_remote_addr zone=four:4m rate=4r/s;
limit_req_zone $binary_remote_addr zone=five:4m rate=5r/s;
limit_req_zone $binary_remote_addr zone=six:4m rate=6r/s;
limit_req_zone $binary_remote_addr zone=seven:4m rate=7r/s;
limit_req_zone $binary_remote_addr zone=eight:4m rate=8r/s;
limit_req_zone $binary_remote_addr zone=nine:4m rate=9r/s;
limit_req_zone $binary_remote_addr zone=ten:4m rate=10r/s;
limit_req_zone $binary_remote_addr zone=twelve:4m rate=12r/s;
limit_req_zone $binary_remote_addr zone=fifteen:4m rate=15r/s;"


No idea what that is but its working for everything but the root of our domain.

Anyone can get us up to 100%?
Find all posts by this user
Quote this message in a reply
06-12-2012, 12:13 PM
Post: #2
RE: Leverage browser caching of static assets. 1 error.
You probably don't want your root domain cached at all. The only reason it is generating an error is because WebPagetest thinks it is static since there are no explicit nocache headers. Is the site php or some other CGI?
Visit this user's website Find all posts by this user
Quote this message in a reply
06-12-2012, 01:33 PM
Post: #3
RE: Leverage browser caching of static assets. 1 error.
(06-12-2012 12:13 PM)pmeenan Wrote:  You probably don't want your root domain cached at all. The only reason it is generating an error is because WebPagetest thinks it is static since there are no explicit nocache headers. Is the site php or some other CGI?

Actually the page IS static.

How do i make explicitly no cache headers in NGINX?

This red X is really bothering me Big Grin
Find all posts by this user
Quote this message in a reply
06-13-2012, 12:07 AM
Post: #4
RE: Leverage browser caching of static assets. 1 error.
You should be able to just define the regex for the URL structure you want to cache and add the expires directly:

Code:
# Set image format types to expire in a very long time
    location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
        expires max;
    }

http://wiki.nginx.org/HttpHeadersModule

Not sure what your URL structure looks like for the HTML but that should give you the basics (maybe something more conservative than max for the expires time).
Visit this user's website Find all posts by this user
Quote this message in a reply
06-13-2012, 12:18 AM
Post: #5
RE: Leverage browser caching of static assets. 1 error.
Well like i said the problem i am getting is not for the images...its for the root level domain "/'.

That is why my score is 95/100. The only thing not being cached is the root domain main page itself. (images are being cached fine)
Find all posts by this user
Quote this message in a reply
06-13-2012, 12:29 AM
Post: #6
RE: Leverage browser caching of static assets. 1 error.
Yes - modify the location regex to include the path to the main page:

Code:
location = / {
        expires max;
    }

http://wiki.nginx.org/HttpCoreModule#location
Visit this user's website Find all posts by this user
Quote this message in a reply
06-13-2012, 07:06 AM (This post was last modified: 06-13-2012 07:07 AM by WebSavvyGuy.)
Post: #7
RE: Leverage browser caching of static assets. 1 error.
Hi Again

I just found this in the etc/Nginx/Vhosts config file for our domain name:


location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|htm|html)$
{
FileETag off;
expires 30d;
proxy_cache mydomain.com-static;


I was wondering what needs to be changed and removed from above there. I think that |htm|html can be removed as i think our host tried to fix it by doing that. The FileEtag is another problem were having as i don't think that thing works also...but as for the issue in this ticket...am i missing a "/" somewhere?

Please advise. I really would like a solution to this.
Find all posts by this user
Quote this message in a reply
06-13-2012, 01:50 PM
Post: #8
RE: Leverage browser caching of static assets. 1 error.
Ok i fixed it...you're right the

location = / {
expires max;
}

code worked.....i just added it underneath my existing images location block
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)