Posted By

dkevey on 11/10/10


Tagged

cahce busting


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


Cache busting script


 / Published in: JavaScript
 

  1. // this goes in the head section
  2. <script type="text/javascript">
  3. <!--
  4. var date = new Date();
  5. var cacheHourly = date.getHours()+"_"+date.getDay()+"_"+date.getMonth()+"_"+date.getYear();
  6. var cacheDaily = date.getDay()+"_"+date.getMonth()+"_"+date.getYear();
  7. var cacheMonthly = date.getMonth()+"_"+date.getYear();
  8. -->
  9. </script>
  10.  
  11. // this goes in the body section
  12. <script type="text/javascript">
  13. <!--
  14. var cache = Math.random();
  15. document.write ('<p class="linkPDF"><a href="somedocument.pdf?cache='+cache+'" target="_blank">Some Document</a></p>');
  16. -->
  17. </script>

Report this snippet  

You need to login to post a comment.