Solved

website errors - browser caching and Vary: Accept-Encoding header

Posted on 2012-03-13
5
544 Views
Last Modified: 2012-03-14
i have a site i am working on,

i get low scores due to these errors,

Leverage browser caching
and
Specify a Vary: Accept-Encoding header

i looked at there links to google, but have not been able to incorporate it into the site.

thanks for your help.

here is an image and link

http://tools.pingdom.com/fpt/#!/OU1lfq4AL/http://fordag.com

errors
0
Comment
Question by:webdott
  • 2
  • 2
5 Comments
 

Author Comment

by:webdott
ID: 37718204
found this - understand it now:

create a notepad file called:

.htaccess

save this in it:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType image/bmp "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType text/xml "access 1 month"
ExpiresByType text/plain "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##

how do i add this to expire?
http://www.google-analytics.com/ga.js

I tried:
ExpiresByType application/js "access 1 month"

thanks for any help
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 37719456
The ga.js is hosted by a different site. Since you are not the owner, you cannot control its caching/expiration.
0
 
LVL 25

Expert Comment

by:kevp75
ID: 37719791
That is not necessarily true gr8gonzo...  you could devise a method to download the js file, and build in a caching mechanism

I do it in .Net
0
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 37720049
@kevp75, if it were a standard JS file that could run locally, I would agree, but typically the JS files from web traffic analysis services like Google Analytics, Omniture, Hitbox, WebTrends, etc... - those NEED to run from the host service. When the browser hits it, the service is notified of that hit. GA may be able to be tinkered with, but it's not the recommended path, nor would it speed up the site at all.

Plus, if Google wants you to cache that file, then by hosting it themselves, they are suppressing a lot of internet traffic overall (if you download it from Site A, then it becomes cached for Site B, C, and D that also use the same file). In fact, webdott could very well be Site B or C or D so it may already be cached by a visitor who has been on a different site that used the analytics JS. By trying to host it himself, he could be adding more unnecessary downloads for his visitor.

Also, most browsers have a limit on how many simultaneous transfers they get from a domain, so by pulling the JS from Google Analytics's domain, you're actually allowing the browser to pull more resources faster (when they don't have it cached). While IE (for example) is pulling 2 resources from webdott's domain, it can also pull the GA resource at the same time. (This is why CDNs can make such a positive impact on performance - it's a divide and conquer strategy).
0
 

Author Closing Comment

by:webdott
ID: 37720212
thanks for explaining it.  it sucks i can't index it to get a score of 100,
but google already does its best to speed the internet.

the site still runs fast. i was just trying to fix all the bugs.

thanks again for your help and detailed info.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now