Force page to reload from server instead of load the cached version

javascript, jquery, php

Solution

OK try this instead:

<?php
    if(!session_id()) {
        @session_start();   
    }
    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
    header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', false);
    header('Pragma: no-cache'); 

    if(isset($_SESSION['form_submitted'])) {
        unset($_SESSION['form_submitted']);
        header('Location: ?' . uniqid());
        #header('Refresh: 0');
    }
?>

You will need to set $_SESSION['form_submitted'] = true on page 2.

Problem

I have webpage A. The user clicks on a form to submit data, and it takes him to webpage B. When he clicks the back button, I need webpage A to be refreshed from the server, rather that loaded from cache. I have this: `<meta http-equiv="expires" content="0">` but it doesnt seem to work. I have also tried setting a variable on page B (session variable via php) and then check for it on page A and refresh (or not) according to its existence. This doest seem to work either. The basic code for that is: Page A: ``` <?php if(isset($_SESSION['reloadPage'])) { unset($_SESSION['reloadPage']); echo' <script> window.location.replace("/****/****/*****.php"); </script> '; } ?> ``` And on page B: ``` $_SESSION['reloadPage'] = 1; ``` With the PHP solution, it simply keeps trying to refresh the page in a never ending loop. Something in my logic missing? Is this the right way to go about it? EDIT Upon further investigation, when you tell the browser to not cache the page, does that force a full server side refresh as well? That's what I need. A full server side refresh of the page.

Original source