When performing a gtmetrix test (gtmetrix) you may see a problem under the Vary: Accept-Encoding area.
There are a few ways to fix this, firstly you can use Cloudflare(CDN) that does it automatically. Another way of solving this is adding it to you .htaccess file directly or adding it to your functions.php file if your using wordpress.
This is what you see in gtmetrix
Place this in your functions.php file, its worked for me 100%
1 2 3 4 5 6 7 |
function add_vary_header($headers) { $headers['Vary'] = 'User-Agent'; return $headers; } add_filter('wp_headers', 'add_vary_header'); |
Or add this to your .htaccess file, sometimes works!
1 2 3 4 5 6 7 |
<IfModule mod_headers.c> <FilesMatch ".(js|css|xml|gz|html)$"> Header append Vary: Accept-Encoding </FilesMatch> </IfModule> |