0

I'm writing a cgi-based web application. In one part of the application you can maintain a list of items, and one of the things you can do is move an item up one spot on the list.

The link for moving an item up looks basically like this:

foo.cgi?action=moveItemUp&itemID=12345

My problem arises when there is an item that I want to move up two spots on the list. I can move it up one spot just fine, but when I click on the "move up" link the second time, the browser won't load the new page. Nothing happens at all.

I think it's because the browser sees that the URL for the new page is the same as the current page and therefore assumes that there is nothing to be done.

I can get around this by changing the link into a form submit button, but I wondered if there are any easier solutions out there.

MrSmith42
  • 9,961
  • 6
  • 38
  • 49
John Gordon
  • 29,573
  • 7
  • 33
  • 58
  • I ended up converting the link to a form submit button, which looks somewhat ugly but A) it works, and B) it conforms to the HTTP expectation that GET requests should not change data on the server. – John Gordon Jun 16 '11 at 21:22

2 Answers2

1

You could have the script send the correct headers telling the browser not to cache the page under any circumstances, or add a random value to the URL:

foo.cgi?action=moveItemUp&itemID=12345&random=23934253094

the header approach would be the cleaner one.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • I tried adding the meta headers, but it had no apparent effect. When I click the "move up" link the second time, nothing happens at all. The browser does not send a request. – John Gordon Nov 10 '10 at 20:40
  • @John ahhh, of course, now I understand - caching is not the issue here at all, the browser just assumes it already is on the right page. Sorry. Yes, in this case a random URL is the only way to go. – Pekka Nov 10 '10 at 20:42
0

Just inform that page must not be cached.

<html>
    <head>
        <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
        <meta HTTP-EQUIV="Expires" CONTENT="-1">
    </head>
    <body>
        (Content)
    </body>
</html>
rsenna
  • 11,775
  • 1
  • 54
  • 60