How to set up nginx cookie free headers

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.

Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Isn’t there a way to provide this under the same host using the rules you’d use for caching specific extensions?

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;
    root /var/www/;

    fastcgi_hide_header Set-Cookie;

Create an A Record for in the DNS section.

Edit your website to make the css, js and image files use this subdomain in its URL.