Forum Moderators: open

Message Too Old, No Replies

I want to reload a page once

         

paste

4:35 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



Basically, I have a page that just doesn't get refreshed/reloaded when it's visited. What I want to do is have a little bit of javascript activated onLoad that refreshes the page, but only once! Any help?

-eric

Pikin_It_Up

4:36 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



I don't understand why the page has to be refreshed. If someone is visiting it, shouldn't it be ready to be viewed?

paste

4:38 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



The reason it needs to be refreshed is that it's a page that shows the contents of a shopping cart, and if the page has already been visited, it won't display changes until it's refreshed.

Sanenet

4:41 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try the "no-cache" META command: <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">

[Added]Stick a random number on the end of the page name so it's always called afresh [/Added]

[edited by: Sanenet at 4:42 pm (utc) on April 8, 2004]

paste

4:42 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



Tried it. I've tried various meta-tags that were suggested to me, all to no avail. So I'm looking for a js solution.

How would i do the random number thing?

Sanenet

4:59 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Several ways: setup URL parsing as directory spoofing (so that me.cfm?a=1 becomes a.cfm/a/1), with the last URL variable a random number. That should confuse the browser into downloading the page each time. (See Amazon for an example)

Or, send the user to mypage.cfm, which redirects to a non existant page which calls a custom 404 creating the information required (or creates a new page with random number and sends you there).

paste

5:07 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



Hmm... I'm not familiar with .cfm files. Also, my shopping cart is run through a perl program that parses the URL anyway, so I suppose it could take care of the random number thing. Or might there be a better way to do it with perl?

Rambo Tribble

2:48 am on Apr 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your problem possibly stems from a server configuration issue. It depends on the server software in use how to make the appropriate changes, but your server can set the refresh frequency of a file.

paste

3:29 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



considering this problem could occur on a number of other systems, i am looking for another method of refreshing the page; one that will at least work on my system, too.

Rambo Tribble

3:43 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See if document.location.reload(true); works for your purposes. You'll probably need to implement a low-persistence cookie as a switch to prevent repetitive reload. As DrDoc suggests, a server-side approach has compelling advantages, not the least of which is improved security.

[edited by: Rambo_Tribble at 4:56 pm (utc) on April 14, 2004]

DrDoc

4:22 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Even though meta tags and JS solutions can sometimes work, the proper way of doing what you want is to pass the appropriate server headers. Are you running on a Unix/Windows server? Is it running Apache? Do you have access to PHP/Perl/ASP?

paste

4:42 pm on Apr 15, 2004 (gmt 0)

10+ Year Member



unix, yes, and i have access to perl; not sure about php or asp. never used them, anyway.

DrDoc

4:51 pm on Apr 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then you can set the no cache headers directly in .htaccess...

paste

5:07 pm on Apr 15, 2004 (gmt 0)

10+ Year Member



sounds good. i'm very inexperienced with .htaccess though, so could i get a bit more help on how to do it? or better yet, could you direct me to a place that could help me figure out how to do it? or better still, both?