Mohon tunggu...
Mboi Coy
Mboi Coy Mohon Tunggu... -

:)

Selanjutnya

Tutup

Nature

What The Hell is Cookie-Free Domain

3 Januari 2011   10:52 Diperbarui: 26 Juni 2015   10:00 174
+
Laporkan Konten
Laporkan Akun
Kompasiana adalah platform blog. Konten ini menjadi tanggung jawab bloger dan tidak mewakili pandangan redaksi Kompas.
Lihat foto
Bagikan ide kreativitasmu dalam bentuk konten di Kompasiana | Sumber gambar: Freepik

If you browse to yahoo.com or facebook.com for example, then try to examine the contain with firebug and you will notice that beside requesting to main domain you will see other domain such as l.yimg.com for yahoo! and static.ak.fbcdn.net for facebook. [caption id="attachment_82739" align="aligncenter" width="300" caption="Yahoo! on Firebug"][/caption] Is a good practise to separate the process between the pages and static components (image, js, css) to achieve good user experience or reduce server load, and you can do that by separating the HTTP process with different web server. The most easy and simple way to do it is by using sub-domain (eg. http://static.domain.com) to serve static request. So what is it? on what consideration we must use not only different secondary-level domain but top-level domain to apply on our site? Well, Let's take a closer look at the process from HTTP Request to HTTP Response by using my favourite plugin for firefox, firebug. Today website is commonly using cookie to store some information regardless what browser they using. for example, user login information, shoping cart or your personal page temporary appearance. When webserver receive the request it will process the request including populating all information that stored on cookies along with other information on request header (user agent, browser capability, referer, etc). When we request a page (HTTP Request) to webserver, all cookies will be send to all HTTP Request include static files. Since the webserver will not process cookies for static files request then is a waste of bandwidth usage either from user or server perspective. Why we not use sub-domain? basically cookies are store relative to main domain. Cookies on sub1.domain.com will be accessible from sub2.domain.com. But domain2.com is unable to access it, even on the same page or request. [caption id="attachment_82836" align="aligncenter" width="946" caption="HTTP Request with Cookies"]

12940461791025077340
12940461791025077340
[/caption] then compare with this request header (different domain) [caption id="attachment_82837" align="aligncenter" width="897" caption="HTTP Request without Cookies"]
12940463291540346295
12940463291540346295
[/caption]

As you can see, even it was request from same page, but the cookies won't be in header if it has different top-level domain So if you have a high traffic website, then you should start to consider to using different domain to serve static files, cookie-free domain. Is a good practice anyway.

Baca konten-konten menarik Kompasiana langsung dari smartphone kamu. Follow channel WhatsApp Kompasiana sekarang di sini: https://whatsapp.com/channel/0029VaYjYaL4Spk7WflFYJ2H

Mohon tunggu...

Lihat Konten Nature Selengkapnya
Lihat Nature Selengkapnya
Beri Komentar
Berkomentarlah secara bijaksana dan bertanggung jawab. Komentar sepenuhnya menjadi tanggung jawab komentator seperti diatur dalam UU ITE

Belum ada komentar. Jadilah yang pertama untuk memberikan komentar!
LAPORKAN KONTEN
Alasan
Laporkan Konten
Laporkan Akun