Search code examples
phphtmldebugginggoogle-chrome-devtoolsfirefox-developer-tools

Remember breakpoints in browser debbuger when the script has parameters (Either Firefox or Chromium)


So I have this code in php in order to avoid caching:

<script src="urlofthescript?v=<?php echo rand(); ?"></script>

But when I'm debugging and assign breakpoints to any line of the script the browser deletes them because it detects the file as a new one, any way to avoid this, or my only option is to just not put the random string, which I'm technically not allowed to do?


Solution

  • Rather than using rand() to tell the browser not to cache the file ever - why not fingerprint the file in some manner. Perhaps using the md5_file function.

    That way whenever the file actually changes so too would the md5 hash. But if the file is unchanged browsers can cache away.