Convince FireFox to refresh page from server on Back

Posted on 2006-05-16
Last Modified: 2012-05-05
Hi Experts.

I am interested in convincing FireFox/IE to refresh a page from the server when the back button is pressed. Basically what I want is that each time a visitor views that page, either by following a link to it or by pressing Back/Forward on his browser if he was previously there, that page should be requested from the server.

Or at least, if that's not possible, make FF execute JavaScript on Back/Forward (see below).

So far, I'm using cache-control, pragma and expires, and it works in IE 6 like a charm.

But no luck with FF.

With FF, even some JavaScript on that page (a simple alert) doesn't execute when I press the back button. So it appears that FF uses a memory cached copy no matter what, and doesn't even execute onload JavaScript when navigating back to that page.

Any ideas how can I force FF to refresh the page from the server when the user presses the back button, or at least make it run the JavaScript code that's on that page?

Thank you.

Catalin Ionescu
Question by:heatseeker
    LVL 30

    Expert Comment

    just add,


    between the head tags.

    Author Comment


    I am already using that, as well as cache-control and expires meta tags, but neither does the job in FireFox.

    What puzzles me even further is that not even JavaScript executes for the back navigation in FireFox.

    Catalin Ionescu
    LVL 10

    Accepted Solution

    The following works for me, but it is important to kill FF before running or the cache is retained.
    <!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-store">
    <script type = "text/javascript">
    alert ("hello world")
    LVL 10

    Expert Comment

    The no-store is what does it - the rest are there for multiple-redundancy and other browsers.

    Author Comment


    Yep, it does indeed work! Thanks a bunch mate. You've saved my sanity, and a few of the remaining hair :)

    Catalin Ionescu
    LVL 10

    Expert Comment

    My pleasure!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Both jQuery and Mootools offer some nice, easy to use scripts. Mootools is best known for their interactive slideshows and jQuery for their menus, but both have many other uses as well.   jQuery is basically a toolkit with many DOM (http://en.wik…
    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now