Solved

Prevent Browser Caching + Flash

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

Accepted Solution

by:
Ray Paseur earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
The viewer will learn how to count occurrences of each item in an array.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now