Solved

Prevent Browser Caching + Flash

Posted on 2010-08-23
5
323 Views
Last Modified: 2012-05-10
I'm using openChart and having trouble with the browser Caching the data provided.. the JSON.

Anyone know how to have it ALWAYS re-load the data and/or Flash upon refresh?
0
Comment
Question by:SMabs
5 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 33505889
Have you got the right expiration META tags?  What headers are you sending with the web page?
0
 
LVL 3

Assisted Solution

by:shawnmstout
shawnmstout earned 125 total points
ID: 33505995
this uses javascript to generate the random number to append to the swf url

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <head>
              <title>No Cache</title>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
              <meta http-equiv="Expires" content ="0" />
                     <meta http-equiv="Pragma" content ="no-cache" />
                     <meta http-equiv="Cache-Control" content ="no-cache" />
              <link href="styles.css" rel="stylesheet" type="text/css">
              <script type="text/javascript" src="swfobject.js"></script>
              <script type="text/javascript">
                  var randomnumber=Math.floor(Math.random()*10000);
                  var flashvars =
                  {
                      foo: "foo".
                  };
                  var params =
                  {
                      allowfullscreen: false,
                      bg_color: '#333333'
                  };
                  var attributes = {};
                  attributes.id = "flashcontent";
                  swfobject.embedSWF("index.swf?"+randomnumber, "alternativeContent", "500", "400", "9.0.115", "expressInstall.swf", flashvars, params, attributes);
              </script>
          </head>
          <body>  
              <div id="alternativeContent">
                      <p>This page requires the Adobe Flash player.<br>
                          <a href="http://www.adobe.com/go/getflashplayer">Download now.</a></p>
                      <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
              </div>
          </body>
      </html>

0
 
LVL 23

Assisted Solution

by:jeremyjared74
jeremyjared74 earned 125 total points
ID: 33506715
The most simple way would be to download the plug-in called Web-Developer Tools. It is available for Firefox and Chrome. The Firefox version seems to work best for me. It has the option to disable cache and or reload different actions on the page.

Firefox Link: https://addons.mozilla.org/en-US/firefox/addon/60/

Chrome Link: https://chrome.google.com/extensions/detail/bfbameneiokkgbdmiekhjnmfkcnldhhm
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 33511110
The appended random number is a great idea.  I've used it before when I am developing CSS files.  You can generate the number in PHP with something like this:

$url .= '?' . urlencode(md5(rand()));

Come to think of it, urlencode() is probably not necessary.

The code snippet shows the headers I have used to prevent cacheing.
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")-2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
        header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

        // THIS HEADER MUST BE OMITTED FOR IE 6+
        if (FALSE === strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE '))
        {
            header("Cache-Control: no-cache, must-revalidate");
        }

        // THIS IS THE LAST HEADER
        header("Pragma: no-cache");

Open in new window

0
 

Author Comment

by:SMabs
ID: 33601513
I ended up dumping OpenChart for FusionCharts..

I had all the tags etc.. but had larger data xFer issues... seems fine now with a better product.

thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

821 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