Solved

Prevent Browser Caching + Flash

Posted on 2010-08-23
5
322 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error log using ftp 7 41
send post values 7 26
Enterprise Mode 4 30
Cookie not unsetting 7 20
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses how to create an extensible mechanism for linked drop downs.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

832 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