etags和普通浏览器提供的缓存之间有什么区别? [英] What is difference between etags and normal browser provided caching?

查看:67
本文介绍了etags和普通浏览器提供的缓存之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

REST允许使用etags进行缓存.

REST allows to use etags for caching.

类似地,浏览器支持缓存,除非设置了以下标头-> maxage,expires,cache-control:private

Similarly browser supports caching unless headers like the following are set -> maxage, expires, cache-control: private

etags与上述缓存方法之间有什么区别?

What is difference between etags and the above mentioned caching approach?

推荐答案

etags与普通浏览器提供的缓存有什么区别?

What is difference between etags and normal browser provided caching?

我想您会发现它们是完全不同的想法.

I think you will find that they are very different ideas.

在HTTP中,缓存语义由 RFC 7234:缓存定义.

In HTTP, caching semantics are defined by RFC 7234: Caching.

实体标签

entity-tag是一个不透明的验证器,用于区分同一资源的多个表示形式,而不管这些多个表示形式是由于资源状态随时间而变化,内容协商导致多个表示形式同时有效还是两者.

An entity-tag is an opaque validator for differentiating between multiple representations of the same resource, regardless of whether those multiple representations are due to resource state changes over time, content negotiation resulting in multiple representations being valid at the same time, or both.

Validator语义用于支持前提条件.两种常见的用例:

Validator semantics are used to support preconditions. Two common use cases:

在有条件GET"方案中,客户端将发送验证器(通过如果-None-Match 标头),用于标识本地已经可用的表示形式.在验证器与当前表示匹配的情况下,服务器可以将响应限制为仅发送刷新的元数据(标头),而不必重新发送资源的表示.

In a "conditional GET" scenario, the client will send validators (via an If-None-Match header) that identify the representations that are already available locally. In the case where the validator matches the current representation, the server can limit the response to only sending refreshed metadata (headers) rather than re-sending the representation of the resource.

在条件PUT"方案中,客户端将发送验证器(通过If-Match 标头),标识请求将要应用于的资源版本.

In a "conditional PUT" scenario, the client will send a validator (via an If-Match header) identifying the version of the resource that the request is intended to apply to.

客户端希望此前提条件是,如果表示数据发生任何更改,则该方法将无法应用.

the client intends this precondition to prevent the method from being applied if there have been any changes to the representation data.

考虑乐观锁定"-我们试图通过确保自服务器最初告诉我们以来资源没有任何其他更改来避免丢失编辑问题".

Think "optimistic locking" - we're trying to avoid the "lost edit problem" by ensuring that there haven't been any other changes to the resource since the server originally told us about it.

这篇关于etags和普通浏览器提供的缓存之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆