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

    Join Date
    Dec 2012
    Rep Power

    PHP command to refresh browser once?


    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.

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Rep Power
    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
    Rep Power

    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
    Tennessee Mountains
    Rep Power
    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.
    Coder Central Tutorials, news and information for the programming community at large.
  8. #5
  9. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    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
    In front of my computer
    Rep Power
    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