4

I am using uploadify. when i try to open the page with uploadify script the page is crashed. I using this for a long time. but now only I am getting the error.

Its happening only in chrome. Its working perfectly in firefox, safari, and IE.

I searched through the google and find a solution like disable cache in the browser(working). But its not the best way to do this in the client browser. Is there any way to disable cache for the specific page using htaccess?

I tried the following in the htaccess. but no use.

<Files jquery.uploadify.js>
    ExpiresDefault "access plus 0 seconds"
</Files>

Please suggest me to solve this problem.

Mahendran Sakkarai
  • 8,381
  • 6
  • 44
  • 66

2 Answers2

23

Finally i solved it by adding an extra parameter(changing the URL or versioning the file) ?ver=<?php echo rand(0,9999);?> to the .js file like below.

<script src="js/jquery.uploadify.min.js?ver=<?php echo rand(0,9999);?>" type="text/javascript"></script>

For more information check this

UPDATE(27-01-2015):

The above solution is not working now. Found another solution. Add timeout around the uploadify function like below will prevent the chrome to crash. Its not the correct solution but it will prevent now. The forum of uploadify also locked. So, I cant able to post a question regard this.

setTimeout(function () {
    $("#uploadify_id").uploadify({})...
},0);

Thanks for everyone.

Community
  • 1
  • 1
Mahendran Sakkarai
  • 8,381
  • 6
  • 44
  • 66
  • 1
    Thanks a lot, we were concidering replacing uploadify in a legacy product. Which would have meant a lot of wasted time. I think you should accept your own answer so others can easily see this works. – martijnve Aug 20 '14 at 08:37
  • 1
    Your approach solved the crash in Chrome and IE. What I did differently was to use the uniqid function that generates unique values. I would also point out that this approach is only valuable if you get errors associated with caching... If you want a caching control i would recommend another approach: http://www.particletree.com/notebook/automatically-version-your-css-and-javascript-files/ or http://blog.greenfelt.net/2009/09/01/caching-javascript-safely/. – Erik Čerpnjak Sep 10 '14 at 08:06
  • This worked for me too. No idea why Uploadify crashes the browser like this? As with the OP this had been working for a long while and only broke in more recent builds of Chrome. Would escalate the issue to the Uploadify team, but they don't appear to run the project from GitHub which is a shame. – SirRawlins Nov 14 '14 at 10:43
  • 1
    **use date("U") instead** of rand(0,9999) - stops the chance of the version not changing and is less code – Sam Doidge Jan 06 '15 at 15:49
2

Put @date("U") after your script src. Like this:

js/jquery.uploadify.min.js?<?=@date("U")?>

It will fix the problem of caching crash.

Ken Le
  • 1,787
  • 2
  • 22
  • 34