We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20751
    • 122 Posts
    Hi,

    Trying to put together my first snippet. It’s a domain name checker that gives the user whois information if the domain is registered and a link to register the domain if it’s available.

    Everything seems to work apart from when I try to go back to the form by hitting the browser’s back button or by clicking the form "back" button I’ve written into the script, I get "Warning Page Expired" error in IE. I figured this must be something to do with caching so I’ve tried calling the snippet cached/uncached and tried setting the page to cahced and not cached and all combinations of the above.

    Still happening. Can anyone tell me what I’m doing wrong?

    Thanks!
      • 7455
      • 2,204 Posts
      try putting this in your snippet:
      header('Cache-Control: private');


      greets dimmy
        follow me on twitter: @dimmy01
        • 20751
        • 122 Posts
        Perfect! Thanks!

        What is that? Why does that work?

        Thanks again!!

        grin
          • 7455
          • 2,204 Posts
          it tels ie to not try to reload the page but to get it from cach
            follow me on twitter: @dimmy01
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Normally, when you try to return to a page where you filled in a form, the form fields (POST) is still available in the browser, including the value from the submit button. The warning is the browser letting you know this. If the receiving page is not coded correctly, all that returning to the page will do is re-submit the same information you already submitted, i.e. the POST values will still be available. That is why a well-crafted script will have something to store and compare a static value (like a timestamp or a generated random value in a hidden form input field), and will simply display the empty form without processing the POST if the values are the same.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 20751
              • 122 Posts
              I see! Thanks for the explanation . . . bit of a noob but I’m learning!

              Thanks smiley