Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Prevent Browser Caching + Flash

Posted on 2010-08-23
5
Medium Priority
?
336 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 111

Accepted Solution

by:
Ray Paseur earned 1000 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 500 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 500 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

722 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