How to tell if loaded file came from cache or not?

Trying to work out how I can tell if a downloaded file came from the cache or was freshly downloaded over the net. I need this because users will download multiple files and I am trying to give make an accurate downloader for them. I have made them download a sample file which I have made not to cache by doing the following:
private var _loader:URLLoader;
private var _rootPath:String; = "http:/example.com/speedTest/f4v/";
private var _startDownloadTime:int;
private var _targetSpeed:Number //set elsewhere
private function loadTestSpeedFile():void
            var fileRequest:URLRequest = new URLRequest();
            fileRequest.url = _fullFilePath + "speedTest.f4v";
            var variables:URLVariables = new URLVariables(); 
            variables.nocache = new Date().getTime();
            fileRequest.data = variables;
            _startDownloadTime = flash.utils.getTimer();
            _loader.load(fileRequest);
private function speedTestHandler(e:Event):void
            var endDownloadTime:int = flash.utils.getTimer();
            var timeElapsed:Number =   endDownloadTime - _startDownloadTime;
            timeElapsed = timeElapsed/1000;
            var bytesPerSec:Number = (SIZE_OF_TEST_FILE/timeElapsed);
            var currentSpeedFactor:Number = bytesPerSec/_targetSpeed;
            trace("Speed Test file downloaded in " + timeElapsed + " secs at " + bytesPerSec + " bytes a sec : speedFactor " + currentSpeedFactor);
               //remove this handler and download as normal from a list of files
            _loader.removeEventListener(Event.COMPLETE, speedTestHandler);
            _loader.addEventListener(Event.COMPLETE, completeHandler);
          //download the rest of the files
            download();
I could work out if the other files are downloading much more quickly (say 20X quicker) than the speedTest rate worked out here and then discount it from calculating the download speed and estimated time remaining.
However, it would be much better if there was a way to access properties on the URLoader on the Event.COMPLETE handler to see if the file 'downloaded' was taken from the cache or not. Anyone know of way of doing it more elegantly than the hack described in the last sentence?

Kglad,
Thanks for the interest and reply. Yes, you are right the file load preventing the file being cached is stictly a different matter from that which is bugging me.  I am, however,  using the Progress Event (as in flash.events.ProgressEvent ) in the following event handler listening to it:
private function progressHandler(e:ProgressEvent):void
            var percent:Number = (e.bytesLoaded/e.bytesTotal)*100;
              //other code to resize the gui loader ie scaling it to the percentage.
Again this just tells me how much has been loaded each time the event is fired. On the Event.COMPLETE handler I am getting the load timings pretty much as per the
speedTestHandler(e:Event) I posted. The only difference there is that it loads from an array of filenames (most but not all of which can change on later replays - hence some will be cached and some not) What i need to know is where the file is loaded from - either from the server or the local systems cache. The only way round this is to discard very quick downloads (which must be from the cache) from true calculating download speeds but that is a bit hit and miss. I am asking for a better solution. Hope that makes sense...

Similar Messages

  • How do I know if this came from Apple or not

    [email protected]
              Today at 8:58 AM
    To
              [email protected]
    Dear [email protected] ,
    Your Apple ID has been disabled for security reasons.
    Someone just tried to log into your Apple account from a different IP address.
Penlight to verify your identity today or your account will be disabled because 
of the concerns we have for the safety and integrity of the Apple community.
    To verify your identity, we recommend that you go to Verify Now>
    Regards,
Apple

    It didn't. Forward it to [email protected] and then delete it.
    (108621)

  • How do I transfer video files shot from my camera (Canon 5DMk2) which is in .MOV format into iTunes ?

    how do I transfer video files shot from my camera (Canon 5DMk2) which is in .MOV format into iTunes ?  My photos and video files are first imported into Aperture then synced with iTunes. However, itunes does not capture the Video files but uploads the phtos from Aperture during sync.
    I tried dragging the video files into iTunes but it still would not be captured into iTunes ?
    Appreciate any help on this. Thanks

    Open them in Quicktime Player 10.1. Then, use Quicktime's Share menu > iTunes.  That will create an iTunes compatible version and automatically load it into your iTunes movie library.

  • How can I best load RAW images from a Canon SX50?

    How can I best load RAW images from a Canon SX50?

    9Sorry, ........confused about this process.   When I attempted to Post the question I had entered, I was told a blank space could not be posted.  So, I reentered the Q in the "space"........ which apparently was the space for an answer....!! ??......)
    >  When I try to load RAW images taken by my Canon SX50 from the SD card, iPhoto 11 -  (iMac/OSX 10.6.8) tells me that it can't read the format or something like that.    OSX 10.6.8 came out before the SX50, thus, did not include the related program.           I want to shoot RAW on the SX50....... but I then want to load them into iPhoto....... which I do directly from pics I take with my Nikon D200.  
    Not sure if this will help.............

  • How to tell if multiple files are selected when they are opened in windows

    Hello, can someone help me, my question is how to tell if multiple file selections were made when they were opened (right-click->open). Through modifying the registry I already have my Java program start up when a file with specific extension is double-clicked.
    The problem is when multiple files are opened at the same time, an instance of java program is created and run for each of the selected files. Ideally I would like it so that only one instance of java program is run, regardless of the number of selections.
    When you try it with Microsoft media player or winamp for example, it seems that only one process is created and run (I don't see many processes spawning when I watch it using task manager). Maybe this is more of Windows issue rather than Java programming issue. Any help is appreciated.

    If anybody wants to know, this can be solved by either 1) using DDE 2) using DropTarget (from Windows) 3) make a light-weight EXE dispatcher (eg. in C), and use file to have IPC between the dispatcher (which gets the filepath for each of the selections) and the java program. There can be other methods of course. Using the second option is the simplest but it requires WinXP and higher. I implemented it using option 3.. the downside of this is there's a warning message pop up when trying to open many (>20?) files at the same time by Windows. However, option 1 'seems' to have the same limitation. Having a java program created each time for each of the selections seems to be too slow, for viable option.

  • How to tell: Which version of camera raw do I have?

    How to tell which version of camera raw I have? The only Google search I found answering this question refers to is 2 years old and seems to no longer apply. There is no File, Edit etc. menu on the new version of Camera Raw with (Photoshop/Bridge CS6). I do use Adobe Application Manager to do my updates telling me if a new version exists or not, nevertheless I would like to know.

    The F key works as described for me in CS6-ACR7.4 with ACR as the window with focus.  The same function is available using the double-arrow-window icon at the right of the Preview checkbox near the top right of the preview area. 
    When in full-screen mode there is no title bar, but when I press the F key or click the double-arrow, again, ACR becomes smaller and I can see the title bar that includes the ACR version and camera model.  This is on Windows7-64-bit on a 1600x1050 monitor.  Perhaps you’re ACR’s title bar is off the top of the screen so you can’t see it, or maybe ACR optimizes some things if you have a smallish display—do you?
    A plug-in is a program that interfaces with another program but is not independently runnable application, itself, bit is independently updatable, so in this instance, Photoshop doesn’t need to be downloaded and installed every time Adobe adds support for a few more cameras.

  • How to import a *.dmp file (exported from 10g) to 8i database?

    Hi everybody!
    Could anybody tell me how to import a *.dmp file (exported from 10g) to 8i database?
    I have tried but it seemed to be error "wrong version".
    Thanks a lot!

    From 10.1.0 to 8.1.7 => Use the EXPORT 8.1.7 to export the data from the 10.1.0 database and IMPORT 8.1.7 to
    import the data into the 8.1.7 database.
    Metalink note 132904.1 Subject: Compatibility Matrix for Export & Import Between Different Oracle
    Nicolas.

  • How could I to load my applet from local

    hI all,
    How can i to load my applet from local file system.
    Thanks

    Put it anywhere you want. Put the associated HTML file in the same directory as your .class file and double click on the HTML file. Your browser should open up and display your Applet.

  • How can I assign image file name from Main() class

    I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
    Here is the Main class
    import org.me.lib.MyJNIWindowClass;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    MyJNIWindowClass mw = new MyJNIWindowClass();
    mw.s = "clock.gif";
    And here is the library class
    package org.me.lib;
    public class MyJNIWindowClass {
    public String s;
    ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
    public MyJNIWindowClass() {
    JLabel jl = new JLabel(image);
    JFrame jf = new JFrame();
    jf.add(jl);
    jf.setVisible(true);
    jf.pack();
    I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
    Thank you.

    Your problem is one of timing. Consider this simple example.
    public class Example {
        public String s;
        private String message = "Hello, " + s;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example();
            ex.s = "world";
            System.out.println(ex.toString());
    }When this code is executed, the following happens in order:
    1. new Example() is executed, causing an object to constructed. In particular:
    2. field s is given value null (since no value is explicitly assigned.
    3. field message is given value "Hello, null"
    4. Back in method main, field s is now given value "world", but that
    doesn't change message.
    5. Finally, "Hello, null" is output.
    The following fixes the above example:
    public class Example {
        private String message;
        public Example(String name) {
            message = "Hello, " + name;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example("world");
            System.out.println(ex.toString());
    }

  • How do I move a file directly from the desktop to a folder in OX 10?

    I am new to Mac and the Mountain Lion software.  Having worked exclusively with PC operating systems, I am familiar with how to work with files in Windows, but am having trouble doing similar actions in OX 10.  How do I move a file directly from the desktop to a folder in OX?  Although this answer is likely in a video tutorioal (somewhere), I do not have the time to sit an arbitrarily watch generic OS videos that give a broad brush overview, without answering specific queries.  Any help out there?

    You might fun http://www.apple.com/support/macbasics/ to be of help to get used to doing things the Mac way.
    Allan

  • How to email a .zip file attachment from PC

    Hi,
    Please, let me know how to email a .zip file attachment from Presentation Server.
    Thanks,
    Madhuri.

    Hi,
    try fm SO_DOCUMENT_SEND_API1
    it's well documented (look with SE37)
    and look here:
    /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
    regards Andreas

  • How to get list of file names from a directory?

    How to get list of file names from a directory?
    Please help

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How do i recover a file deleted from iCloud on my iPad

    how do i recover a file deleted from iCloud on my iPad? It's a pages document

    check at https://www.icloud.com/ to see if the file is saved there in documents or iCloud drive
    if not check under settings > iCloud > storage > manage storage and see if there is a backup of the iPad from when the document was still saved
    if there is restoring your iPad form that backup may recover it
    Restore your device from an iCloud or iTunes backup - Apple Support
    if there is not then check to see if it is still saved on any other computers or devices to see if it is saved there
    good luck

  • Ust purchase an iphone 4s and need to know how could i transfer all files including (contacts, pictures, music, notes and ect.... from sd card or any external card to iphone 4s, please advise thx

    ust purchase an iphone 4s and need to know how could i transfer all files including (contacts, pictures, music, notes and ect.... from sd card or any external card to iphone 4s, please advise thx.

    You need to put all of your info on your computer and then sync it to iphone.

  • Whit the new iTunes how i can down load my pictures from the iPhone to the computer  to make more spaces

    whit the new iTunes how i can down load my pictures from the iPhone to the computer  to make more spaces

    Hi shadibader,
    I understand that you wish to import your photos onto your computer from your iOS device. Here is an article for you that will explain how to accomplish this:
    Import photos and videos from your iPhone, iPad, or iPod touch to your Mac or Windows PC - Apple Support
    http://support.apple.com/en-us/HT201302
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

Maybe you are looking for

  • G3 Beige: grey screen at startup; no icon; won't boot from CD

    G3 Beige, OS 9.2; working perfectly for past year. I was using a D-Link wired router, to this and my other Mac, G4 Graphite OS X Tiger. Having just gotten a netbook, I installed a D-Link wireless router (DIR-615), and changed the ethernet cables for

  • No split screen in CONVERSATIONS

    So I had Swype installed on my N8 and did an OTA update to Anna. And yes after the initial install I installed the 4 other packages (Nokia Anna 1/2, 2/2, Ovi Store & Social).  I found that I didnt get a split screen anywhere. On Googling I found that

  • Possible to Exclude a specific intersection from DATAEXPORT?

    Version: 11.1.2.2 Is it possible to Exclude a specific intersection from a DATAEXPORT in an Essbase Calc Script? I am able to exclude a member but I only want to exclude 1 intersection. Simplified Cube: Fund Dimension Center Dimension Account Dimensi

  • After updating, I only see the window border, Firefox is not rendering.

    The browser toolbars, windows, everything is invisible. I only get the border of the window. This is more than just missing toolbars - there are no toolbars, no minimize/maximize/close icons, nothing but the window border.

  • Re-oganizing Library...

    I am fairly new to the Mac environment after switching from PC so please be patient with me as Im learning the file structure, etc. I have quite a large library going with my photo's. They are not organized very well now - most of them were brought o