#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    PHP command to refresh browser once?


    Hi

    What is the PHP command that tell the browser to simply refresh the screen once in order to make sure that the content of that page is truely updated.

    Thanks,
    N.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,617
    Rep Power
    595
    There isn't one. Refreshing the browser is client side action while PHP is server side.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    refreshing the whole page is also a rather ugly way to update data. I hate pages that do this.

    Most of the time it isn't even necessary, because people usually don't stay on a single page for hours or something. But if you do think you need it, use AJAX to reload specific parts of the page.
  6. #4
  7. Web Developer/Musician
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Nov 2004
    Location
    Tennessee Mountains
    Posts
    2,411
    Rep Power
    1032
    As mentioned a total refresh isn't very user friendly and takes up network bandwidth that you may not need to do if the amount of data to be updated is small. Sure you could use a javascript window.location call or an HTTP refresh but you may be better off polling via AJAX for new info and sending it back with the response if there is any.
  8. #5
  9. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,302
    Rep Power
    9400
    If you're having caching problems then that's something you should specifically deal with. Out of the box you should be fine so it probably means something was added to instruct browsers to cache pages.

    If you have dynamic content on the page that needs to be refreshed... once ... then a meta refresh or AJAX is best.

    Otherwise what problem are you trying to solve, and (if it's not obvious) why do you think refreshing the page is the solution?
  10. #6
  11. Known to taste like chicken
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    In front of my computer
    Posts
    399
    Rep Power
    312
    read up on the cache-control headers. http://www.w3.org/Protocols/rfc2616/...4.html#sec14.9

    you should be able to set the max-age of the page to something small which will force all (good) caches to revalidate. If you are expecting people to sit on the page for a long time and you want it to refresh, then you should do like everyone above me in this thread has said, and use ajax.
    Last edited by sir_drinxalot; December 30th, 2012 at 04:01 AM.
    "Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe

    Looking for a project Idea?

IMN logo majestic logo threadwatch logo seochat tools logo