Mobile app version of vmapp.org
Login or Join
Gail5422790

: Why does Pingdom suggest that I add a "Vary: Accept-Encoding" header? I have tried a tool to measure the speed of my web site. It is Pingdom https://tools.pingdom.com There is an answer I do

@Gail5422790

Posted in: #CacheControl #HttpHeaders #PageSpeed

I have tried a tool to measure the speed of my web site. It is Pingdom tools.pingdom.com
There is an answer I do not understand
"The following publicly cacheable, compressible resources should have a "Vary: Accept-Encoding" header: www.example.com/

Can anyone explain what is that in a simple way and how can I improve it?

If I understand that is related to the way files are compressed. My server does not accept Gzip. It works well with deflate. I put that code in the .htaccess:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript


It works well for Google page speed. But it seems that Pingdom still gives an error.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

3 Comments

Sorted by latest first Latest Oldest Best

 

@Nickens628

One main reason to use "Vary: Accept-encoding" is as Oskar mentioned, to allow content to be delivered based on what the browser is capable of.

"Accept-encoding" is an especially important parameter for the "Vary" header as it allows proxies (middle-man servers) to properly understand that multiple compressed versions of your page can be cached in the proxies and therefore, your web page will be loaded fast for the new browsers that support compression, and uncompressed for older browsers that don't support compression.

This URL explains very well why vary is extremely important and even indicates you can save money as a result of using it:
www.fastly.com/blog/best-practices-using-vary-header/

10% popularity Vote Up Vote Down


 

@Mendez628

What is it?

The Vary HTTP response header tells user agents (clients) that the server's response can vary if the client changes any of the mentioned request headers.

Vary: Accept-Encoding


This means that if the browser sends a different value in the Accept-Encoding request header, the server might send a different response.
(It should be noted that the Accept-Encoding header says which compression algorithms the browser supports, character encodings are called charsets in HTTP.)



The reason why the header is ever needed is that there can be a cache between the user agent (browser) and the server, and that cache needs to know that the same page can have different content for different user agents. If the server didn't send a Vary header, an intermediary cache could cache a "weird" variant of a page and serve it to everybody, examples:


Sending a "mobile page" to desktops.
Sending the page compressed with an uncommon/unsupported compression method.
Sending the page in a language you don't speak.


Failing to send the Vary header can cause any intermediary cache to ruin your site.



Some examples of other headers that are ¿commonly? mentioned in the Vary header:


User-Agent: Commonly used by sites that serve separate mobile and desktop pages on the same URLs. (Some search engines, including Google, require that you use the Vary header if you use this method.)
Accept-Language: An internationalized site can use the Accept-Header sent by the browser.




How to improve?

Honestly: It's not the most important Vary header to have. Most browsers support gzip, so it's unlikely that you actually need to implement it.

But I wouldn't say that, would I. I like being pedantic about these kinds of things, so I would suggest you take a look at this question at Stackoverflow that asks how to implement it.

10% popularity Vote Up Vote Down


 

@Candy875

Just check out the below Link, You will find the answer by yourself. stackoverflow.com/questions/16642190/how-to-specify-a-vary-accept-encoding-header

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme