Solved

Prevent Browser Caching + Flash

Posted on 2010-08-23
5
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 110

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 110

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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 …

628 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