Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m4v visible in cache but browser loads it again #20

Open
videophonegeek opened this issue Aug 21, 2012 · 7 comments
Open

m4v visible in cache but browser loads it again #20

videophonegeek opened this issue Aug 21, 2012 · 7 comments
Labels

Comments

@videophonegeek
Copy link

Using Safari 5.1.7 on OSX 10.6.8. I use html5Preloader to preload the next clip .m4v that will play. Under resources it is shown to be in cache, but when the next clip is activated, Safari goes back to the server and downloads it again. Then the preloader loads the next one into cache. Same behavior with .webm on Firefox.

@jussi-kalliokoski
Copy link
Owner

Hello!

Thanks for reporting!

Sounds really weird, could you provide a provide a reduced to test case so I could reproduce and try to debug it?

Thank you very much!

Cheers,
Jussi

@videophonegeek
Copy link
Author

Hi Jussi, This morning I double checked my .htaccess file to ensure it had all the correct cache expiry info.  It looks like this:

1 WEEK

<filesMatch ".(jpg|jpeg|png|gif|swf|m4v|mp4|ogv|webm|flv)$">
Header set Cache-Control "max-age=604800, public"

Code is pretty simple.  

I use maximizr to determine the type of video supported by the browser to do the preload.
Manipulate innerHTML to use the cached video. Browser reloads the cached video.

I'm on satellite internet so it really becomes apparent when things are not used from cache!  I'll try to distill this down to a couple lines of working code for you.


From: Jussi Kalliokoski [email protected]
To: jussi-kalliokoski/html5Preloader.js [email protected]
Cc: John Feagans [email protected]
Sent: Wednesday, August 22, 2012 2:23 AM
Subject: Re: [html5Preloader.js] m4v visible in cache but browser loads it again (#20)

Hello!
Thanks for reporting!
Sounds really weird, could you provide a provide a reduced to test case so I could reproduce and try to debug it?
Thank you very much!
Cheers,
Jussi

Reply to this email directly or view it on GitHub.

@videophonegeek
Copy link
Author

Jussi, Just learned something interesting. I was testing Safari on Mac OSX which exhibited the problem with not using cache.  Firefox did the same with webm.  However, Chrome works perfectly!  It uses the cached videos from html5preloader and works smoothly.  All browsers latest for HTML5 support. I will check iPad, iPhone, Android, and PC


From: Jussi Kalliokoski [email protected]
To: jussi-kalliokoski/html5Preloader.js [email protected]
Cc: John Feagans [email protected]
Sent: Wednesday, August 22, 2012 2:23 AM
Subject: Re: [html5Preloader.js] m4v visible in cache but browser loads it again (#20)

Hello!
Thanks for reporting!
Sounds really weird, could you provide a provide a reduced to test case so I could reproduce and try to debug it?
Thank you very much!
Cheers,
Jussi

Reply to this email directly or view it on GitHub.

@jussi-kalliokoski
Copy link
Owner

Thanks John, I think I have a pretty good guess of what's wrong here.

First of all, you don't need to detect the supported media types, html5Preloader does it for you:

myLoader.addFiles('videoname*:res/videoname.ogv||res/videoname.webm||res/videoname.m4v')
myLoader.on('finish', function () {
  /* this will be the first supported video */
  myLoader.getFile('videoname')
})

But that's not the cause for a double cache hit, but instead because (I presume) you create another video element in the innerHTML. Instead, you could do something like this:

myLoader.on('finish', function () {
  containerElement.replaceChild(
    myLoader.getFile('currentclip'),
    myLoader.getFile('previousclip')
  )

})

Which would replace the previous clip with the already created video element. I suspect that Chrome doesn't have the issue because of its more aggressive caching.

Cheers,
Jussi

@videophonegeek
Copy link
Author

Hi Jussi,

I tried all the things you mentioned below and no change but the simplest case is pre-load an m4v and a png into Safari without doing anything.  Looks at the stats recorded:

name1318718566941.m4vradio_Checked_Med.png
methodGETGET
statuspendingpending
typeundefinedimg/png
size05.73k
time12ms421ms
timeline...

The m4v is never actually preloaded.   The load from the


From: Jussi Kalliokoski [email protected]
To: jussi-kalliokoski/html5Preloader.js [email protected]
Cc: John Feagans [email protected]
Sent: Wednesday, August 22, 2012 11:18 AM
Subject: Re: [html5Preloader.js] m4v visible in cache but browser loads it again (#20)

Thanks John, I think I have a pretty good guess of what's wrong here.
First of all, you don't need to detect the supported media types, html5Preloader does it for you:
myLoader.addFiles('videoname_:res/videoname.ogv||res/videoname.webm||res/videoname.m4v') myLoader.on('finish', function () { /_ this will be the first supported video */ myLoader.getFile('videoname') })
But that's not the cause for a double cache hit, but instead because (I presume) you create another video element in the innerHTML. Instead, you could do something like this:
myLoader.on('finish', function () { containerElement.replaceChild( myLoader.getFile('currentclip'), myLoader.getFile('previousclip') ) })
Which would replace the previous clip with the already created video element. I suspect that Chrome doesn't have the issue because of its more aggressive caching.
Cheers,
Jussi

Reply to this email directly or view it on GitHub.

@jussi-kalliokoski
Copy link
Owner

I'm really sorry for forgetting about this, I suppose you worked around it somehow?

@videophonegeek
Copy link
Author

Hi Jussi,

Never found a work-around for Safari at that time.  I have not tried the latest version of Safari as I have moved on to other projects. I will be doing another jquery project soon so maybe we can explore more at that time?

On Tuesday, October 15, 2013 5:25 AM, Jussi Kalliokoski [email protected] wrote:

I'm really sorry for forgetting about this, I suppose you worked around it somehow?

Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants