Cheap VPS host selection
Provide server host evaluation information

Introduction to the method of automatically updating cache after modifying CSS style in PbootCMS

Generally speaking, after the style is modified, because the browser caches the online website and simply refreshes it unchanged, you need to force a refresh to see the effect immediately. Sometimes the customer can't see the effect of the modification and has to explain it. In fact, you can add a version number to the modified style, so that you can refresh to see the latest style.

Common methods of manually adding version numbers

<link rel=”stylesheet” href=”{pboot:sitetplpath}/css/common.css? V=1 ″>/plus? v=1, Every subsequent number change
Is there any way to make the version number automatically change every time, and change only when there is a change to refresh, and not when there is no change to refresh.

This automatic method is available, and the following describes the related operations.

1. First add an automatic time version number method. It is recommended to add it to the general method file on the website.

Find the file apps/common/function.php, and then add a new method at the end

function ver($url){
$ver = filemtime($_SERVER[‘DOCUMENT_ROOT’].$url);
echo $url.’?v=’.date(“YmdHis”,$ver);
}

2. Modify the original call style link (note that the original resolved path must be manually copied in, and the path can be viewed by ctrl+u in the browser to copy the source code)

PB material network, pbootcms template technology network, pbootcms source code network

/Original

<link rel=”stylesheet” href=”{pboot:sitetplpath}/css/common.css”>

/Modified

<link rel=”stylesheet” href=” {php}ver (‘/template/default/css/common.css’); {/php}”>

Then, when the style is modified in common.css, save it, and refresh the page, you will find that the style tail has a string of time version numbers, so you can see the style changes when you refresh.

Supplement: In fact, external files of js can also be operated in this way. Just like css, you can experience it yourself.

Do not reprint without permission: Cheap VPS evaluation » Introduction to the method of automatically updating cache after modifying CSS style in PbootCMS