Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the names of some css, js files have random numbers in them?

Some websites seem to have file names such as 'assets/app-02b4523sev8fsd56e.js'. I have noticed that these numbers do not change though, so I thought it has something to do with security but I am not sure. Is there any reason behind this?

like image 492
blank_kuma Avatar asked Dec 24 '22 18:12

blank_kuma


1 Answers

This is normally to break caches stored by the browser so that the latest version of a file is loaded. Every time a file is changed this value will normally be changed also. This can be done manually by changing the filename and/or the paths in other files referencing this file, or this can be done programatically in some way. You may also see this done like the following and it may also contain a timestamp rather than a hash like the above:

assets/scripts.js?v=20150611190618

This is often referred to as a 'cache-buster' amongst other names.

like image 171
Remote Avatar answered Feb 01 '23 23:02

Remote