Home > Software engineering >  What names should js files have, to which urls with a strange ending lead: ".../filename.js?crc
What names should js files have, to which urls with a strange ending lead: ".../filename.js?crc

Time:09-19

In html pages, I saw some strange are the paths to js documents:

— attached the code at the end of the question —

I noticed the "?crc=6" after the usual ".js". As I understand it, "?crc=6" is used to indicate the version of this file in case any of its previous editions will be in the browser cache. There were presumably five of them here (each time the file was changed in the URL this number also changed so that the browser considered the file different and did not take the old one from the cache). What names should the js files to which these links lead have? Should they be spelled out together with "?crc=6" or use a simple notation with ".js"?

<script src="/js/jquery.fancybox.min.js?crc=6" type="text/javascript"></script>
<script src="/js/jquery.cookie.js?crc=6" type="text/javascript"></script>
<script src="/js/popper.min.js?crc=6" type="text/javascript"></script>
<script src="/js/bootstrap.bundle.min.js?crc=6" type="text/javascript"></script>
<script src="/js/bootstrap.min.js?crc=6" type="text/javascript"></script>
<script src="/js/jquery.formstyler.js?6" type="text/javascript"></script>
<script src="/js/wavesurfer.min.js?6" type="text/javascript"></script>
<script src="/slick/slick.min.js?6" type="text/javascript"></script>
<script src="/js/common.js?99" type="text/javascript"></script>    

I noticed the "?crc=6" after the usual ".js". As I understand it, "?crc=6" is used to indicate the version of this file in case any of its previous editions will be in the browser cache. There were presumably five of them here (each time the file was changed in the URL this number also changed so that the browser considered the file different and did not take the old one from the cache).
What names should the js files to which these links lead have? Should they be spelled out together with "?crc=6" or use a simple notation with ".js"?

CodePudding user response:

The filename on the webserver should end in only .js. Question marks are invalid in filenames anyway on some operating systems.

The only purpose of the query parameter is to force the client to make a new request to the webserver if that version of the script is not in the browser cache yet - on a static site, a request to /js/jquery.fancybox.min.js?crc=6 will result in the site returning the file located at /js/jquery.fancybox.min.js.

  • Related