Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug cache-busted scripts in production

I am working on a front-end project (JavaScript files) and the server adds a cache-busting value to the end of the URL, e.g., http://www.example.com/myfile.js&bust=0.5647534393

My problem is I lose any breakpoints set in Chrome's Developer Tools after reloading. I do not have access to the server to disable it.

Is there any way to work around this constraint?

UPDATE: Adding debugger; to the JS source code is not a viable solution because I'm debugging production code.

like image 317
Arashsoft Avatar asked Mar 04 '16 20:03

Arashsoft


2 Answers

You can use a URL-rewrite Chrome plugin like Requestly (not free) or Redirector (free) and add redirect rule for your scripts.

Requestly for example lets you specify rules like:

Requestly rule screenshot

I'm OFC assuming that if you strip the ?bust=xxxx part from the URL the server will still serve the correct script file. I tested it and it works like a charm in my local test environment - the breakpoints remain.

Hope it helps.

like image 141
jannis Avatar answered Sep 22 '22 15:09

jannis


You can use debugger; within your code. If the developer console is open, execution will break. It works in firebug as well.

like image 42
Oscar Bout Avatar answered Sep 21 '22 15:09

Oscar Bout