Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Browser cache issue

  • 28-08-2008 8:35am
    #1
    Closed Accounts Posts: 518 ✭✭✭


    hey,

    was wondering if there is a few nice lines of php code or something to lash in a .htaccess file that will force the latest copy of my web pages to the user as opposed to whats in their cahe?

    I had a holding page and now i have over written it with the finished site. now for some users they have to ctrl + f5 to force a fresh download themselves...


Comments

  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭oeb


    Put this at the top of your document

    [PHP]
    <?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    ?>
    [/PHP]


  • Closed Accounts Posts: 518 ✭✭✭danbhala


    thanks, I'll test it out


  • Registered Users, Registered Users 2 Posts: 2,120 ✭✭✭p


    Doing that kind of thing is a bad idea. It could affect the performance of your site quite a bit.


  • Closed Accounts Posts: 518 ✭✭✭danbhala


    even for a small site? its only 4 php pages and a few images


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭oeb


    p wrote: »
    Doing that kind of thing is a bad idea. It could affect the performance of your site quite a bit.

    +1

    (Just aswering his question though :) )


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭oeb


    danbhala wrote: »
    even for a small site? its only 4 php pages and a few images

    Caching basicially means that the files are stored on a users machine and pulled from there instead of from the server. By telling the browser not to cache, the files have to be downloaded from your server.

    This means more bandwidth for you, and more downloads for your visitor.


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Why do you want to prevent cache searches?


  • Registered Users, Registered Users 2 Posts: 2,120 ✭✭✭p


    danbhala wrote: »
    even for a small site? its only 4 php pages and a few images
    It's not going to make a huge difference for a site that small, but I'm guessing the reason you're asking this is because you've got a confused client :)

    Caching works properly for normal visitors. Probably won't have a big impact on a site that small, but I still wouldn't advise it as a general practice.


  • Closed Accounts Posts: 518 ✭✭✭danbhala


    basically I had a holding page for a site thats been up for a few days. It went live this morning and got a few phone calls saying it wasnt working for them. even though it was for me because I usually ctrll + refresh to make sure I see my changes... so basically their browser was using the cache version as opposed to the live and they had no idea how to refresh it themselves :|

    The site is only up for a week and its also a password protected and just being used internally for the company... so i'm not really concerned about bandwidth... just trying to get them off my back!


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    danbhala wrote: »
    basically I had a holding page for a site thats been up for a few days. It went live this morning and got a few phone calls saying it wasnt working for them. even though it was for me because I usually ctrll + refresh to make sure I see my changes... so basically their browser was using the cache version as opposed to the live and they had no idea how to refresh it themselves :|

    The site is only up for a week and its also a password protected and just being used internally for the company... so i'm not really concerned about bandwidth... just trying to get them off my back!
    Note that the reason some of your customers might not have being able to see it is because the holding page may have beign on a different server different webserver and it could have taken time for DNS to propagate across ISPs. It may not have being to do with cache's what so ever. Just a thought.

    Edit - See it was actually cached alright (gotta read to end of posts) - some people don't know what or where the refresh button is? :confused: tut tut

    :)


  • Advertisement
  • Closed Accounts Posts: 429 ✭✭Myxomatosis


    Just a little tip as we're on the subject of caching.

    If you ever want a browser to be forced to download a fresh copy of a page or file, e.g. a file who's contents are being dynamically changed on the server, all you have to do is append "?blah" to the end of the link / redirection.
    test.php?blah 
    sample.htm?blah
    style.css?blah
    
    Of course the word does not need to be blah, I usually run a random number function.
    Works great no matter how many proxies or caches you are behind.


Advertisement