I have an nginx server and can\'t seem to find any information on how to send Vary: Accept-Encoding headers for CSS and JS files. Does anyone have info about this?
Thank
Simple. In Nginx conf:
vim /etc/nginx/nginx.conf
Add the following near the bottom under the section:
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
Just uncomment the gzip_vary on;
parameter and restart or reload nginx service:
service nginx restart
This should fix the issue. If you are running an old version of nginx, you may need to enable gzip on;
, as this is required for the vary header to work.
I hope this helps. FYI, this applies to all server/site conf files unless overwritten in their own respective server blocks. server {}
Source info for nginx, apache and IIS: https://www.maxcdn.com/blog/accept-encoding-its-vary-important/