Add ?v= version number after js or css to prevent browser caching

Add ?v= version number after js or css to prevent browser caching

Copy code
The code is as follows:

<span style="font-size:14px;">css and js with parameters (such as .css?v= and .js?v= or .css?version= and .js?version= )
<script type=”text/javascript” src=”jb51.js?version=1.2.6″></script>
<link rel='stylesheet' href='base.css?version=2.3.3′ type='text/css' />

There are two possibilities for using parameters:

First, the script does not exist, but is dynamically generated by the server, so it has a version number to distinguish it. That is, the above code is equivalent to the file

Copy code
The code is as follows:

<script type=”text/javascript” src=”jb51.js”></script>
<link rel='stylesheet' href='base.css' type='text/css' />


But the browser will think it is a certain version of the file!

Second, the client will cache these css or js files. Therefore, every time the js or css file is upgraded and the version number is changed, the client browser will re-download the new js or css file, which serves the purpose of refreshing the cache. Sometimes you may find that after you modify the style or js, it remains unchanged when you refresh it. This is because the client has cached the CSS or JS file, so adding parameters is still helpful!
The second situation is the most common, but both may exist at the same time. </span>

<<:  Summary of Common Terms in CSS (Cascading Style Sheet)

>>:  How to use Flex layout to achieve scrolling of fixed content area in the head

Recommend

The corresponding attributes and usage of XHTML tags in CSS

When I first started designing web pages using XH...

Docker installs mysql and solves the Chinese garbled problem

Table of contents 1. Pull the mysql image 2. Chec...

Nginx source code compilation and installation process record

The installation of the rpm package is relatively...

Example code for implementing auto-increment sequence in mysql

1. Create a sequence table CREATE TABLE `sequence...

CentOS7 deployment Flask (Apache, mod_wsgi, Python36, venv)

1. Install Apache # yum install -y httpd httpd-de...

Teach you how to use docker-maven-plugin to automate deployment

1. Introduction to docker-maven-plugin In our con...

A brief discussion on using Vue to complete the mobile apk project

Table of contents Basic Configuration Entry file ...

Detailed explanation of Linux kernel macro Container_Of

Table of contents 1. How are structures stored in...

How to use HTML form with multiple examples

Nine simple examples analyze the use of HTML form...

Design a data collector with vue

Table of contents Scenario Core Issues Status mon...

Tips on disabling IE8 and IE9's compatibility view mode using HTML

Starting from IE 8, IE added a compatibility mode,...

Analyze the method of prometheus+grafana monitoring nginx

Table of contents 1. Download 2. Install nginx an...