×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT杂谈 / Back, Back, Back, .... Jabber seeks your help!
    本文发表在 rolia.net 枫下论坛Dear Friends, I have a seemingly simple issue to consult with you.

    Context: Let me say I am doing E-commerce things. I have two pages.
    Page A displays un-placed order items in a shopping card and a Button
    named "Place Order". Once I hit the "Place Order" button, the Http Request will be send to the server (Whatever it is). After the order is processed, server will send a response--- Page B. Now, now, the user may hit the "Back" button on the browser menu and see page A again. It is likely that the user will click the "Place Order" button in Page A again and re-place the order. This will be a big problem.

    Requirement: I don't want to show the Page A again after the order has been placed. Idealy, as the user clicks the "back" button on the menubar of the browser, I should pull a new page (But with the same URI as page A) that tells the user "You have no items in your shopping cart" or "There is no item in your shopping cart".

    Analysis: This is completely a client-side problem. There is no thing to do with server-side. In priniclple, it should be resolved using Client-side Script. However, VB script should be excluded because or corporate politics.

    State of Issue: I have already tried to seek advice from the people around me. But I have not yet seen the solution. At the very beginning,
    my manager advocated that the issue was a piece of cake. He suggested solving the problem by using META tag in the header of Page A . It turned out to be a No-Go. Indeed, people can set Expires and
    Cache-Control (or Pragma) in the META tags, but they are meaningful ONLY for the proxy server. My issue has nothing to do with the proxy, because what the user sees second time is a cache in the Browser,
    not in the proxy. In other words, as the user hits the "back" button, the browser does not send any request to the server (via the proxy).
    Actually, what I need is NOT using the cache in the browser, I hope to send a request to server so as to refresh the page.

    Thanks: For your advice.更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • Try there META tags. Hopes it is helpful.
      response.setHeader("Expires", "Thu, 01 Jan 1901 00:00:00 GMT");
      response.setHeader("Pragma", "no-cache");
      response.setHeader("Cache-Control","no-cache");
      response.addHeader("Cache-Control","no-store");
      • Thank you, bloor. Your trick applies to proxy ONLY, not to Browser.
        I am considering using JavaScript to manupilate Cookies on the client -site.

        If you keep an eyes for the issue I cited here, you will see that some commercial sites have not taken care of this problem. Alas.
        • The Meta tags of setting "expire" and "no-cache" do work. I used that kind of method before, no matter using proxy or not.
          • Dear Sailor, thanks for your response.
            I guess you have overlooked my issue. What I meant by "Back" is
            clicking "Back" button on the menu bar of the browser.
            • I did meet the same problem as yours, ecommerce shopping site, and no back button.....
    • My two cents
      I used to have the same problem in my former projects. I remember the best solution that we found finally is to use a tranfer page between page A and page B. Then you can easily get the source of the request if it's from A or B and give response respectively.
      • Thanks, Peter. Likewise, I guess you misundertood my issue. As the user cliks the "Back" button on the menubar of the browser, he/she see the cach in the browser.
    • Try. Your requirement: Don't want to show the Page A again after the order has been placed.
      Your requirement: Don't want to show the Page A again after the order has been placed.
      Solution:
      Please try location.replace() in JavaScript.
      If you use location.replace("URL of page B") in the page A to open the page B, the URL of page A will not appear in the history list of the BACK button on the menubar of the browser, so user
      can not return to the page A from the page B by click the BACK button.
      • HH has saved me. Merci Beaucoup!
        • De Rein! (After visited 3 public libraries and looked through several huge dictionaries.)
          • De rien! De rien! De rien! De rien! :-) :-) ;-;-):
            • Sorry! De rien! De rien! De rien! De rien! De rien! De rien! De rien! De rien! De rien! ... Remember in my heart.