In web development, you may have noticed instances where parameters are added to CSS or JavaScript link files. This practice, represented by strings such as src="../cnt.js?ver=4.0", serves a specific purpose.
Despite the notion that JS/CSS files cannot directly receive parameters, the reason for passing them lies in cache control. When a client requests a file with a certain URL, the browser typically stores it in its cache for subsequent requests to optimize loading times. However, this can become problematic when changes are made to the files and you want clients to download the updated versions.
By passing a parameter like "?ver=4.0", you can force the browser to ignore its cache and fetch the file directly from the server. This is especially useful when deploying new application versions or making updates to CSS/JS files. By appending a unique version number or timestamp parameter, you ensure that clients always receive the latest version of the asset.
So, while CSS and JavaScript files themselves cannot read the passed parameters, they serve as a mechanism to control caching and ensure that clients always have up-to-date versions of your files.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3