Would this piece of code in Nginx configuration file remove cookie headers?
server {
fastcgi_hide_header Set-Cookie;
}
I am asking this is because I am getting a F from Yslow (Gtmetrix testing). It says that my website’s many js. css, jpg files are NOT cookie-free.
My server is setup with EasyEngine, Nginx.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
When your website sets a cookie, the web browser sends this cookie when requesting static files like js, css and png. This increases network activity.
Being cookie free means using a different domain or subdomain for serving files like images, stylesheets and Javascript.
So you need to create a new virtual host file on Nginx with the same document root:
server {
listen 80;
server_name static.example.com;
root /var/www/example.com;
fastcgi_hide_header Set-Cookie;
}
Create an A Record for static.example.com in the DNS section.
Edit your website to make the css, js and image files use this subdomain in its URL.
https://gtmetrix.com/use-cookie-free-domains.html http://serverfault.com/q/78227
Isn’t there a way to provide this under the same host using the rules you’d use for caching specific extensions?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.