cookies和缓存的区别_Cookies和缓存之间的区别

cookies和缓存的区别

Here you will learn about difference between cookies and cache i.e. cookies vs cache.

在这里,您将了解Cookie和缓存之间的区别,即Cookie与缓存之间的区别。

Both are downloaded to your computer but they have different purposes. Cookies are download to record your previous activities on a particular website. On other hand Cache are used to store the web-pages in memory so when user visits that webpage again then webpage can be loaded from the memory instead of downloading files from web-server again.

两者都下载到您的计算机上,但它们具有不同的用途。 Cookies被下载以记录您以前在特定网站上的活动。 另一方面,缓存用于将网页存储在内存中,因此当用户再次访问该网页时,可以从内存中加载网页,而不必再次从Web服务器下载文件。

Cookies和缓存之间的区别 (Difference between Cookies and Cache)

 Cookies                               Cache
1. What isSmall files downloaded to your computer to track your previous  activity.Files downloaded to your computer memory to store the current version of the webpage so  next time browser doesn’t need to download all the files again from the internet when we visit that webpage again.
2. AdvantagesLess memory, no extra burden on server, simple to use and implement.Faster access, save time, save data.
3. SizeCan support as large as 4kb, 50 cookies per domain (per website), can support at least 3000 cookies in total.Depend on the limit set by your internet browser.
4. DisadvantagesSecurity risk because of its clean plain text. User can disable cookies, User can delete cookies, Track browsing activities.Sometimes websites loaded from cache can be different from the website on internet.
5. ExpiresExpires after sometime.Kept in the client’s machine until they are removed manually by the user.
饼干 快取
1.什么是 将小文件下载到您的计算机以跟踪您以前的活动。 文件已下载到您的计算机内存中以存储网页的当前版本,因此下次我们再次访问该网页时,浏览器无需再次从Internet下载所有文件。
2.优势 更少的内存,对服务器没有额外的负担,易于使用和实现。 更快的访问,节省时间,保存数据。
3.尺寸 最多可以支持4kb,每个域(每个网站)50个cookie,总共可以支持至少3000个cookie。 取决于您的Internet浏览器设置的限制。
4.缺点 由于其纯净的纯文本,因此存在安全风险。 用户可以禁用cookie,用户可以删除cookie,跟踪浏览活动。 有时,从缓存加载的网站可能不同于Internet上的网站。
5.过期 一段时间后过期。 保留在客户端计算机中,直到用户手动将其删除为止。

Let’s see these differences in detail.

让我们详细了解这些差异。

What is: Cookies (also known as web-cookie, internet cookie or browser cookie) are small files downloaded to your computer. These files are sent from the website that we’re browsing and downloaded by web browser to our computer.

什么是: Cookies(也称为Web cookie,Internet cookie或浏览器cookie)是下载到您计算机上的小文件。 这些文件从我们正在浏览的网站发送,并通过网络浏览器下载到我们的计算机。

These small files may have the information like which links you’ve been visited, buttons you clicked, your log in information, or the pages were visited in the past. When we’ll visit that website next time then the website will use that information to track our previous activity on their website. It can also remember the information that previously entered into form fields like name, date, birth detail, credit card number etc.

这些小文件可能包含以下信息:访问过的链接,单击的按钮,登录信息或过去访问过的页面。 当我们下次访问该网站时,该网站将使用该信息来跟踪我们先前在其网站上的活动。 它还可以记住以前输入到表单字段中的信息,例如姓名,日期,出生详细信息,信用卡号等。

On other hand, Cache is nothing but some downloaded files in memory which is used by browsers to access web-pages with high speed. When we open a webpage, the pages and all its files are downloaded as browser’s cache in our computer hard drive. When we visits that webpage again, if the resources and dependencies of that web page are still same as our last visit, then browser will fetch that entire webpage or some files of that webpage from the hard drive instead of downloading it from web server, which will increase the speed of accessing that webpage. It will save our time and data too. It holds the resources like files, audio, video and flash files.

另一方面,缓存只不过是内存中的一些下载文件,浏览器可使用这些文件来高速访问网页。 当我们打开网页时,页面及其所有文件将作为浏览器的缓存下载到我们的计算机硬盘中。 当我们再次访问该网页时,如果该网页的资源和依存关系与上次访问相同,则浏览器将从硬盘驱动器中获取整个网页或该网页的某些文件,而不是从Web服务器下载该网页或将提高访问该网页的速度。 这也将节省我们的时间和数据。 它包含文件,音频,视频和Flash文件等资源。

Advantages: There are many advantages of cookie like it doesn’t take much memory in our computer and storing the cookies on client-side reduces the burden from the server. Cookies are also easy to use and implement.

优点 :cookie有很多优点,例如它不需要占用我们计算机中的大量内存,并且在客户端存储cookie可以减轻服务器的负担。 Cookies也易于使用和实现。

Whereas, Cache improves the browsing experience by increasing the speed of accessing websites. As previously mentioned that if the resources of that particular website are still same then the browser will fetch that website or some files from the computer’s hard drive. Which will save our time and data too.

而Cache通过提高访问网站的速度来改善浏览体验。 如前所述,如果该特定网站的资源仍然相同,则浏览器将从计算机的硬盘驱动器中获取该网站或某些文件。 这也将节省我们的时间和数据。

Size: Cookies can be up to 4KB (4096 Bytes) in size, and a website can send 50 cookies on our computer and the number of total cookies can be at least 3000.

大小: Cookies的最大大小为4KB(4096字节),一个网站可以在我们的计算机上发送50个cookie,并且cookie的总数至少应为3000。

On other hand, the size of cache depends on the limit set by browser. You can increase the size to store more temporary files using browser’s settings.

另一方面,缓存的大小取决于浏览器设置的限制。 您可以使用浏览器的设置来增加存储更多临时文件的大小。

Disadvantages: Cookies exists as plain text on the client machine, so it can be a security risk because anyone can open and tamper with cookies. Anyone can disable and delete cookies in Browser’s setting.

缺点: Cookies在客户端计算机上以纯文本形式存在,因此存在安全风险,因为任何人都可以打开和篡改Cookies。 任何人都可以在浏览器的设置中禁用和删除Cookie。

Whereas, the main disadvantage of loading webpage from cache can be different from the website presented on the web-server, because cache may have the results from your visit on that website.

然而,从缓存加载网页的主要缺点可能与Web服务器上显示的网站有所不同,因为缓存可能会带来您访问该网站的结果。

Expires: Cookies after a set time and the time of  expiration also depends on the type of cookies.  For example –  session cookie exists only in temporary memory while the user navigates the website.  Web-browsers  normally delete session cookies when user closes the browser. Persistent cookie expires on a set time by its creator.

过期:经过一定时间设置的Cookie和过期时间也取决于Cookie的类型。 例如,会话cookie仅在用户浏览网站时存在于临时内存中。 当用户关闭浏览器时,网络浏览器通常会删除会话cookie。 永久性Cookie由其创建者在设定的时间到期。

On other hand, Cache will not expire until  user deletes it by himself  or the memory allocated for cache runs out of memory.

另一方面,直到用户自己删除高速缓存或为高速缓存分配的内存用完内存后,高速缓存才会过期。

Comment below if you have queries related to above difference between cookies and cache.

如果您对以上Cookie和缓存之间的差异有疑问,请在下面评论。

翻译自: https://www.thecrazyprogrammer.com/2018/02/cookies-vs-cache.html

cookies和缓存的区别

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值