SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast somnath's Avatar
    Join Date
    Jun 2005
    Location
    India
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to clear cache in IE using PHP

    I have written a ajax application with auto page refresh in php. But while running this application on IE I have faced a problem that the refreshen data don't show in the browser.It get stored in the cache.
    I have add the the following code for clearing cache, but it does not work.

    header('Expires: Fri, 25 Dec 1980 00:00:00 GMT'); // time in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
    header('Cache-Control: no-cache, must-revalidate');
    header('Pragma: no-cache');

    Please suggest a solution...
    Somnath Guha

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You can't clear a user's cache with PHP or any other language. Plus PHP only works on the server so it can't affect the browser's behavior.

  3. #3
    SitePoint Enthusiast somnath's Avatar
    Join Date
    Jun 2005
    Location
    India
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what is the solution for me in this problem. Can it be handled by javascript?
    Somnath Guha

  4. #4
    SitePoint Enthusiast somnath's Avatar
    Join Date
    Jun 2005
    Location
    India
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code is running ok in firefox mozilla(autometically shows the updated data in auto page refresh). But not worked in IE.
    Somnath Guha

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    those headers should work, assuming they are being sent for the resource that should be cached. for example, if you dont want an image cached, you would send those headers for the image itself, not the html page which links to the image.

    if IE cached it before you added those headers, you might need to first clear your cache before it will start working.

    another possible solution is to keep changing the query string for the url each time you send a request.
    Code:
    var date = new Date();
    var url = 'http://example.com/script.php?foo=' + date.getTime();


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
  •