Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 23

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    4,503

    Default Forced Refresh of Browser

    I built a webpage for a neighborhood initiative and regularly have to add updates to reflect new developments. However, when neighbors try to visit the page many actually see an older, cached version. Often they don't know how to force their browsers to refresh and with all the different devices and browsers out there, it would be difficult to give them directions how to. Therefore I would like to add some code to the page that forces their browsers to refresh every time they visit the site.

    I remember that at some time this issue has been discussed on this forum, including directions as to what code to use. I also remember that pros and cons to such solutions were mentioned but I can't find the thread anymore.

    I did find some code when googling (such as, <A HREF="javascript:history.go(0)">Click to refresh the page</A>) but I'm not really sure about it, so I would really appreciate some help on this issue.

  2. #2
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,842

    Default Re: Forced Refresh of Browser

    Relatively tricky. I use this approach sometimes when checking download times.

    Add a button to the page with link: javascript:location.reload(true);
    This forces a server call for the page, bypassing the cache.

    Details here: https://www.w3schools.com/jsref/met_loc_reload.asp

    A link with javascript:location.reload(false); is the same as the viewer pressing browser F5 or the Reload this page icon.
    A link with javascript:location.reload(true); is the same as the viewer pressing browser Ctrl+F5, to clear the browser cache BUT only for the specific page.

    For Supersites, one button call may be enough, for Conventional you may need a button a page.

    I do not recommend the HTML pragma no-cache as this means the page is never cached and this has consequences for download times.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  3. #3
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    927

    Default Re: Forced Refresh of Browser

    That is interesting Acorn. Maybe it could be combined with the use of local storage, or even without if the server supports PHP...
    Looks like being worth to experiment a bit.

  4. #4

    Default Re: Forced Refresh of Browser

    When I am developing I set the expire tag, usually for a single day, until development is finished, though sometimes I'll set it for 30 days. I have also used the no cache during development as I could care less if the client uses bandwidth, it is removed after site approval.

  5. #5
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,842

    Default Re: Forced Refresh of Browser

    Quote Originally Posted by mwenz View Post
    When I am developing I set the expire tag, usually for a single day, until development is finished, though sometimes I'll set it for 30 days. I have also used the no cache during development as I could care less if the client uses bandwidth, it is removed after site approval.
    And sometimes we forget, i have.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  6. #6

    Default Re: Forced Refresh of Browser

    I've never forgotten. I keep a small notebook for each job. First page is dedicated to what I need to do for a real release--and there more in that page than caching options. There are pages for thoughts on future updates, etc. The notebook goes into the front of the client file. It's the first thing I see when I revisit a job.

  7. #7
    Join Date
    Mar 2009
    Posts
    4,503

    Default Re: Forced Refresh of Browser

    Quote Originally Posted by mwenz View Post
    When I am developing I set the expire tag, usually for a single day, until development is finished, though sometimes I'll set it for 30 days.
    Thanks for the suggestion, Mike. How would I do this?

  8. #8

    Default Re: Forced Refresh of Browser

    If your server runs on apache you should be able to set expiry for all different types of files in .htaccess including HTML files generated by xara.
    Here's an example one I found on a search but I changed the line with HTML to 60 seconds. You could change it to whatever is suitable.
    So you would add a section like this to your .htaccess file in the root folder where your .htm files are.

    <ifModule mod_headers.c> Header set Connection keep-alive
    <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=2592000, public" </filesMatch>
    <filesMatch "\\.(css)$"> Header set Cache-Control "max-age=604800, public" </filesMatch>
    <filesMatch "\\.(js)$"> Header set Cache-Control "max-age=604800, private" </filesMatch>
    <filesMatch "\\.(xml|txt)$"> Header set Cache-Control "max-age=86400, public, must-revalidate" </filesMatch>
    <filesMatch "\\.(html|htm|php)$"> Header set Cache-Control "max-age=60, private, must-revalidate" </filesMatch>
    </ifModule>

  9. #9
    Join Date
    Mar 2009
    Posts
    4,503

    Default Re: Forced Refresh of Browser

    Quote Originally Posted by Acorn View Post
    Relatively tricky. I use this approach sometimes when checking download times.

    Add a button to the page with link: javascript:location.reload(true);
    This forces a server call for the page, bypassing the cache.
    Acorn, thanks. I used this option and it works fine. Of course, people who don't do a refresh themselves don't see the button yet but I'll inform them by email.
    By the way, you say it's relatively tricky to use such an approach. Why is that?

  10. #10
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,842

    Default Re: Forced Refresh of Browser

    Quote Originally Posted by Boy View Post
    Acorn, thanks. I used this option and it works fine. Of course, people who don't do a refresh themselves don't see the button yet but I'll inform them by email.
    By the way, you say it's relatively tricky to use such an approach. Why is that?
    Probably a dislike of a web application controlling a part of my computer; an elective button is OK but having my 'Precious' Cache purged without notice is worrying.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

 

 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •