简体   繁体   中英

Why linking an external javascript with ?variable=value

I have seen code like this:

<script type="text/javascript" src="js/my_js.js?id=<?php echo time(); ?>"></script>

I do not understand the reason for the id, nor how to use the id in the .js file, if this is possible.

Thanks.

It is to force the browser to refresh the JavaScript file, otherwise the browser may display a cached version at a later date.

You can also do this to CSS files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM