过期值如何用于Cookie和缓存? [英] How do expire values work for cookies and caching?

查看:291
本文介绍了过期值如何用于Cookie和缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过期值总是困惑我,因为客户端的时间设置可以完全不同于服务器。我想知道在幕后发生了什么。



说我的服务器的时区是GMT +1,客户端的时区是GMT + 2.如果我现在创建cookie with as expires value: current_timestamp + 31 * 86400 (过期在31天),浏览器如何知道正确的时间?到期时间是否转换为GMT值,然后由浏览器转换为客户端的正确时区?


解决方案

Cookie过期标题的格式包含时区,因此Cookie何时过期不会出现歧义



http://www.cookiecentral.com/faq/#3.2

  Set-Cookie:foo = bar; path = /; expires Mon,09-Dec-2002 13:46:00 GMT 


Expire values have always confused me, since the time settings of the client can be completely different from the server's. I'd like to know how what happens behind the scenes.

Say my server's timezone is GMT +1 and the client's timezone is GMT + 2. If I now create a cookie with as expires value: current_timestamp + 31 * 86400 (expire in 31 days), how does the browser know the correct time? Are expire times converted to GMT values and then by the browser converted to the right timezone of the client? Or must they always be in GMT value?

Caching times probably have the same mechanism, if not please elaborate.

解决方案

Cookie expires headers are in a format that includes the timezone, so there is no ambiguity as to when the cookie will expire

http://www.cookiecentral.com/faq/#3.2

Set-Cookie: foo=bar; path=/; expires Mon, 09-Dec-2002 13:46:00 GMT

这篇关于过期值如何用于Cookie和缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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