开发者

Problem with redirecting using header location and IE9 cache

开发者 https://www.devze.com 2023-03-14 06:57 出处:网络
I have a problem using PHP header location with IE9. For a e commerce website I add products to a cart using a link like /cart/add/id-of-product.htm (/cart/add/233.htm). The page behind it adds the p

I have a problem using PHP header location with IE9.

For a e commerce website I add products to a cart using a link like /cart/add/id-of-product.htm (/cart/add/233.htm). The page behind it adds the product to the cart and redirects the user to /cart.htm. Everything works perfect in FF. It even works in IE9, until someone tries to add the same product to the cart again. IE 'thinks' he can go directly to the /cart.htm page and skip my code where I try to add the product to the cart. Somehow IE caches information about the redirect, but why? The link behind the 'add to cart' button clearly shows the link /cart/add/233.htm, but if you click it it just skips the page... I tried to put a ?r=random-number (/cart/add/233.htm?263663746) behind it, but this does not matter.

Does anyone know how to avoid this? I want to redirect the user after they added a product to the cart, but how do I a开发者_如何学Pythonvoid this IE thing?

Thanks for your time!


Internet Explorer caches HTTP/3xx redirects as allowed by the RFC. If you don't want a given redirect to be cached, you need to use a HTTP/302 without a future Expires or max-age. You explicitly don't want to use a HTTP/301.

(Your attempt to put a random query string in the URL would have worked if you had done it properly, but you did something wrong there.)

0

精彩评论

暂无评论...
验证码 换一张
取 消