preventing IE from Cacheing video's?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
myister
Forum Newbie
Posts: 12
Joined: Tue Sep 28, 2010 7:03 am
Location: Ohio
Contact:

preventing IE from Cacheing video's?

Post by myister »

Ok I have looked into how to stop browsers from storing a video in its cache once watched. So I moved to check out my script in IE and found that the video was in the cache not matter what I did. So I looked into this and found that IE does not allow the header feature to disable its cache of a video. BUT it does allow you to change how long the video is in the cache before being deleted.

So if I was to through time limit in the header of a video being played through php could I some what stop the issue with IE?

Like say the video is 1 min long and I changed the limit to like 1 min and 30 sec or something.

Has anybody ever looked into something like this when showing movie files though php using headers?

Thanks

justin
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: preventing IE from Cacheing video's?

Post by josh »

You can't even stop a wmv from being hotlinked in any browser. The solution is to alter the URL such that you generate a unique token and then serve the video thru the PHP script. Without a valid token you will assume its a hotlink request. Due to the URL changing with the token it will not be cached either.
User avatar
myister
Forum Newbie
Posts: 12
Joined: Tue Sep 28, 2010 7:03 am
Location: Ohio
Contact:

Re: preventing IE from Cacheing video's?

Post by myister »

Yea thats what I have done

pretty much I did this

uploaded a video through my script putting it in a protected folder. then assigns the video a Key 10 Chars long and stores the realvideo location along with the Key in a MySQL DB. When the link streamvideo.php?ID=abcdefg is used the streamvideo.php scripts $_GET (s) the key and queries the database looking for the key and then serving the real Location of the video to PHP and I use readfile() to get the contents of the video.
I added header()'s to stop cache of them in most browsers. IE does not follow the no-cache rule. ( verified through microsoft )
but it does honor the time limit for storing the cache.
I also added a .htaccess file to the default video DIR "deny from all" and then "allow from ***.***.**.**" which stops hot linking. I also added some sessions to the streamvideo.php file.

My question was. Can I use a header to limit the time the video stays in the Cache for IE while at the same time using the no-cache for all the other broswers?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: preventing IE from Cacheing video's?

Post by josh »

myister wrote:I also added a .htaccess file to the default video DIR "deny from all" and then "allow from ***.***.**.**" which stops hot linking. I also added some sessions to the streamvideo.php file.
That is not a solid approach to stop all hotlinking.
My question was. Can I use a header to limit the time the video stays in the Cache for IE while at the same time using the no-cache for all the other broswers?
I don't see why not. Just pass both headers.
User avatar
myister
Forum Newbie
Posts: 12
Joined: Tue Sep 28, 2010 7:03 am
Location: Ohio
Contact:

Re: preventing IE from Cacheing video's?

Post by myister »

I am going to try to do the both header thing and see how that works.
That is not a solid approach to stop all hotlinking.
What other way could I stop direct hotlinking if the real DIR that holds all the real movies was found?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: preventing IE from Cacheing video's?

Post by josh »

Like I said, create a token and pass it in the URL. Only allow one request per token, so someone could hotlink a video but they would have to go thru a greater ordeal (scraping the page to get valid tokens each time)
Post Reply