Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cgi scripts and caching (and also location redirects)

Status
Not open for further replies.

m4trix

Vendor
Jul 31, 2002
84
CA
Ok, I wrote a simple script that allows the users to enter a headline and some news, and with the click of a button, post it on the main page of his site. Well, it works great for the most part. There is a preview option, as well as password authentication.

When my employer uses the preview option, it works fine, but when he presses "back" to get back to the form, everything he entered is cleared, so he has to type it all over again. The same thing happens if he forgets to enter a password or enters an invalid one. It is obviously a setting with his browser's caching, as it works fine on my computer and every one I've tried it one. While I could tell him to change the settings on his browser, I was wondering if anyone could think of a way to get the script to "remember" what's been entered either if he visits the preview or the invalid password dialog.

It had occured to me to write what he enteres to a temporary file, but that would be inefficient. I also considered writing a hidden form to the preview and invalid password pages, and having him click a "back" button that submits the data back to the script. Lastly, and probably the best method, would be to use browser cookies. (there is not a large amount of data entered so it should be fine). If anyone has any suggestions that would be great.



SECONDLY, when the script does post the news, I want it to return to the index of the home page.
If I do "Location: /index.html\n\n" it works fine, but in the address bar is the location of the script, so if I reload, it tries to reload the script and not the page. Is there any way to not have this happen without printing a short meta or javascript redirect page?

thanks
 
1a. - write a cookie that holds the headline and news info
1b. - it's just as easy to write to an array and pass the value back to the page.

2 - rather than use "Location: /index.html\n\n", use the URL address: This will ALWAYS be the index.html file.

There's always a better way...
 
1) Is he hitting the back button and pressing f5?, that's different to pressing back, or hitting backspace in that "BACK" will go to the last locally cached entry, which "might" contain the variables sent to the script (F% will cause a refresh, and when the page is re served it won't maintain the previous context.. Watch exactly what he's doing, and the behaviour will most likely be consistent among the majority of browsers

2) Pointing to a site's root will return index.htm, index.html (ht*), default.ht*, main.ht*, or whatever the server is configured to serve as the default page for the root directory (or any subdirectory) depending on the server

You don't have to write a temporary file, just write the relevant header to the browser(incl meta http-equiv), and have that redirect to result

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Paul,
1) he is actually clicking the "back" button in the browser. I don't know if it matters, but it's a mac running MacOS 9.1 I believe, and IE 5.5 (mac version obviously). But I've tried it on other macs with the same setup and it works fine. It must be settings he has made to his browser

2) I know about pointing to a site's root, but it didn't occur to me at the time :) Plus, right now I'm testing the script & site locally, so I don't currently know the final address of the site right now. That's why I just set it to /index.html. But thanks, I'll find that out and change it.
 
m4trix,

Give him the same specification of the machine you have, including any required software preinstalled, flog it to him, and when it doesn't work anymore (ie after he's changed something) it's a problem for his techs, and not you...unless...

It's more than likely a security setting, get him to add your site as a trsuted site, and that might get you out of jail - it's just a term (b4 anyone says it again)

Without having access to the bogey it's going to be hard to compare settings against ;(

Regards
Paul
 
yeah I know. I've talked to him about it, he agrees, but both of us are too lazy to go comparing settings between the two machines :p

I'm sure we'll figure it out. Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top