Cache busting script


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.