Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoiding cookies while requesting static content

I just did an audit of one of my web application page (built using ASP.Net and running on development server) using Google chrome's developer tool. One particular warning caught my eyes:

Serve static content from a cookieless domain (5)!

I would like to know is it possible to avoid cookies for these kind of requests. I see that there is no cookie requests for javascript files as well. I it possible to avoid cookies in the header for these files as well? and why didn't the browser attach cookies for javascript files and attach for CSS and image?

like image 265
Abdel Raoof Olakara Avatar asked Feb 16 '26 07:02

Abdel Raoof Olakara


1 Answers

Cookie are "attached" to a domain and a path. If you set cookies for a path above your files, they'll be sent with any request for those files.

The warning message itself tells you how to fix this - use another domain for your static content. Or a subdomain, as long as you make sure you keep your main domain cookieless in that case.

like image 82
Matti Virkkunen Avatar answered Feb 17 '26 23:02

Matti Virkkunen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!