Link in JavaScript file cannot be updated

I am currently working on my project and I have encountered a problem while building a QR code scanner for my website.

The problem is that whenever I have scanned the QR code, my latest javascript link is not updated even though I have tried so many approach in order to make the JavaScript file to force reload such as the getting version method using JavaScript, PHP and so on.

This is the code in my php file for the QR code scanner:

<script type="text/javascript" src="js/app.js?v=5"></script>

Other methods like using time as the version:

<?php echo '<script type="text/javascript" src="js/app.js?v='.time().'"></script>'; ?>

And another method using PHP:

function auto_version($file='') {
        return $file;

    $mtime = filemtime($file);
    return $file.'?'.$mtime;

<script type="text/javascript" src="<?php echo auto_version('js/app.js'); ?>"></script>

By the way, the library that I am using for the QR code scanner is InstaScan library.

Can anyone suggest a method to make it work?

Thank you in advance.