11

We are developing a Flash site with PHP. the problem is that it storing the cache , but we have to disable the cache using JavaScript or PHP.

How can I disable caching?

fabrik
  • 14,094
  • 8
  • 55
  • 71

2 Answers2

24

A common practice to disable browser caching is to set an expiration to a date in the past in the HTTP header. Different browsers utilize HTTP header values differently so it is important to use many if not all of the following settings:

<?php
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>

Read more about the header function on the PHP website.

cowgod
  • 8,626
  • 5
  • 40
  • 57
  • 1
    In the PHP docs, they only mention the Cache-Control and Expires directives. Any official documentation on your solution? What are your references? Thank you. – Mario Awad Apr 17 '11 at 12:59
6

Try loading the movie with a query string, that should disable the cache. Note that the query string should be different every time.

<parm name='movie' value='movie.swf?ran=sfkjfsdkf23123'>

You could for example use php to create a random query string.

Pim Jager
  • 31,965
  • 17
  • 72
  • 98