Internet Explorer 10后退按钮缓存 [英] Internet Explorer 10 back button caching

查看:127
本文介绍了Internet Explorer 10后退按钮缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Internet Explorer 10中,如果按后退按钮,它将尝试从浏览器缓存中获取上一页。此行为与几乎所有其他浏览器(包括IE9)不同,其中按后退按钮将完全重新加载上一页而不是重新使用缓存。

In Internet Explorer 10, if you press the back button it would try to fetch the previous page from the browser cache. This behavior differs from virtually every other browser including IE9 in which pressing the back button would do a full reload of the previous page instead of reusing the cache.

我如何从网站上与IE10进行通信,可能使用javascript / headers等来不对全球网站进行此缓存利用?

How do I communicate with IE10 from the website, possibly using javascript/headers etc to not do this cache utilization for the site globally?

(注意:我不是在寻找IE10设置来禁用它。我正在寻找一种可以在网站上实现的解决方案而不是浏览器来指示IE10不使用此缓存后退按钮)。此外,我正在寻找适用于网站中每个页面的全局解决方案......

(Note: I'm not looking for an IE10 setting to disable this. I'm looking for a solution that can be implemented in the Website and not the browser to instruct IE10 to not use this cache for the back button). Also I'm looking for a global solution that works for every page in the site...

我使用PHP / Jquery作为网站

I use PHP/Jquery for the site

该页面是一个表格。它包含一些动态加载的信息。 (假设它包含用户提交表单的次数)

The page is a Form. It contains some dynamically loaded info. (Let's say it contains the number of times the user submitted the form)

单击表单的提交按钮。然后,您将被重定向到表单的操作页面。

You click on the submit button of the form. You will then then get redirected to the form's action page.

然后按后退按钮。

在所有其他浏览器中,它会使用新更新的用户提交表单的次数重新加载初始表单。然而,在IE10中,这不会发生....如何在IE 10中实现这一点。

In every other browser, it would reload the initial form with the newly updated "number of times the user submitted the form". In IE10 however, this doesn't happen....How do I get this to happen in IE 10.

以下是一些示例标题:

请求标题

Key Value
Request GET /path/to/my/page HTTP/1.1
Accept  text/html, application/xhtml+xml, */*
Accept-Language en-US
User-Agent  Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Accept-Encoding gzip, deflate
Host    myhost.com
If-Modified-Since   Tue, 10 Sep 2013 23:55:33 GMT
If-None-Match   "1378857333"
DNT 1
Connection  Keep-Alive
Cookie  __utma=104299925.1011127538.1340896287.1364829735.1378764406.12; __utmz=104299925.1340896287.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); has_js=1; __utmc=104299925; __qca=P0-1247924781-1340896285157; _mkto_trk=id:601-CPX-764&token:_mch-sadfsadfze.com-1358808312889-73607; __utma=171146939.775168663.1343066079.1375907514.1378762647.41; __utmz=171146939.1343066079.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); s_stats_browser_info=%7B%22pluginInfo%22%3A%7B%22pdf%22%3A%5B%22pdf%22%2C%22application/pdf%22%2C%220%22%5D%2C%22quicktime%22%3A%5B%22qt%22%2C%22video/quicktime%22%2C%220%22%5D%2C%22realplayer%22%3A%5B%22realp%22%2C%22audio/x-pn-realaudio-plugin%22%2C%220%22%5D%2C%22wma%22%3A%5B%22wma%22%2C%22application/x-mplayer2%22%2C%220%22%5D%2C%22director%22%3A%5B%22dir%22%2C%22application/x-director%22%2C%220%22%5D%2C%22flash%22%3A%5B%22fla%22%2C%22application/x-shockwave-flash%22%2C%220%22%5D%2C%22java%22%3A%5B%22java%22%2C%22application/x-java-vm%22%2C%221%22%5D%2C%22gears%22%3A%5B%22gears%22%2C%22application/x-googlegears%22%2C%220%22%5D%2C%22silverlight%22%3A%5B%22ag%22%2C%22application/x-silverlight%22%2C%220%22%5D%7D%2C%22res%22%3A%221920x1080%22%7D; _pk_id.2.1644=19232922ec6753dc.1371502517.1.1371502630.1371502517.; SESS569093948b0206b05eb2212616da3db6=1977iogjr841af2s8l4sd1cjd0; XDEBUG_SESSION=12250; has_js=1; __utmc=171146939

响应标题:

> Key   Value Response  HTTP/1.1 200 OK Date    Tue, 10 Sep 2013 23:55:44 GMT
> Server    Apache/2.2.20 (Ubuntu) X-Powered-By PHP/5.4.15-1~tooptee10+1
> Last-Modified Tue, 10 Sep 2013 23:55:44 +0000 Cache-Control   no-cache,
> must-revalidate, post-check=0, pre-check=0 ETag   "1378857344"
> Keep-Alive    timeout=15, max=9987 Connection Keep-Alive
> Content-Type  text/html; charset=utf-8



2。当您点击后退按钮返回该表格时



请求标题

2. When you hit the back button to go back to that form

Request Header

>     Key   Value
>     Request   GET /path/to/my/page HTTP/1.1
>     Accept    text/html, application/xhtml+xml, */*
>     Accept-Language   en-US
>     User-Agent    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
>     Accept-Encoding   gzip, deflate
>     Host  myhost.com

响应标题

> Key   Value Response  HTTP/1.1 304 Not Modified
> X-Powered-By  PHP/5.4.15-1~tooptee10+1 ETag   "1378857344"
> Keep-Alive    timeout=15, max=9987 Content-Type   text/html; charset=utf-8
> Content-Length    117183 Expires  Tue, 10 Sep 2013 22:55:36 GMT
> Last-Modified Tue, 10 Sep 2013 23:55:44 GMT

请注意,它最终返回304.当我在Firefox中尝试此操作时,当您按下后退按钮时它返回200。

Notice that it ends up returning a 304. When I tried this in Firefox, it returned 200 instead when you press the back button.

推荐答案

我认为你想要的行为是打破用户后退按钮期望的行为。

I think the behaviour you want is a behaviour that breaks the expectation of the back button for users.

用户希望当他们按下时,它会将它们返回到他们之前查看的页面,处于他们离开时所处的状态。大多数现代浏览器不仅通过缓存页面,而且通过在内存中保留页面状态(包括Javascript上下文)来实现这一点,这样当通过后退按钮返回页面时,它处于以前的状态,包括它们的任何状态写入表格或他们与之互动的任何Javascript。

Users expect that when they press back, it returns them back to the page they were previously viewing, in the state it was in when they left it. Most modern browsers achieve this by not only caching the page, but by retaining the page state (including the Javascript context) in memory so that when returning to the page via the back button, it's in the same state it was before, including anything they wrote into forms or any Javascript they interacted with.

在大多数浏览器中, 可以通过设置 Cache-强制覆盖它控制标题,例如 no-cache no-store 。我不知道<* c $ c> no-store 是否可以用于IE10,或者如果IE10忽略了这一点,无论如何都会回到页面。如果确实如此,我认为我不会真的责备它。这样做是为了让用户感兴趣的是快速,并且返回到以前查看时的页面。

In most browsers you can forcibly override this by setting Cache-Control headers such as no-cache and no-store. I don't know if no-store would work in your case for IE10, or if IE10 ignores even this and just goes back to the page anyway. If it did, I don't think I'd really blame it. It's doing it in the user's interest of both being fast, and of returning back to the page as it was when it was viewed before.

我认为我会采用的方法拿,你不必同意我,就是重新思考设计。如果你不打算向他们展示他们 那时他们看到的那个东西,你为什么要求用户回?如果您想要显示更新的表单,为什么不将在POST后重定向返回到表单,将被视为新页面加载并尊重您的 Cache-Control 标题?这就是我要做的事情,它已成为一种事实上的标准。

I think the approach that I would take, and you don't have to agree with me, is to re-think the design. Why do you require users to hit "back" if you are not going to show them the same thing they saw when they were back there? If you want to show an updated form, why not redirect after POST back to the form, which will count as a new page load and honor your Cache-Control headers? That is what I'd do and it's become somewhat of a de-facto standard.

tl; dr 这是可能的,但我是不确定,你可以用 no-store 做你想做的事,但我会考虑转移到在POST后重定向,以便不依赖后退按钮来恢复以前的状态。

tl;dr it's possible, but I'm not certain, that you could do what you want with no-store, but I'd be looking at moving to redirect after POST instead so as not to rely on the back button for something other than going back to the previous state.

这篇关于Internet Explorer 10后退按钮缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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