Answer the question
In order to leave comments, you need to log in
What is this setting in NGINX settings?
Hello, there is an nginx vhost config, where it says:
location ~* ^.+\.(css|js)$ {
root "%hostdir%";
#rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, no-transform";
}
rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
Answer the question
In order to leave comments, you need to log in
This is a regular expression: ^(.+)\.(\d+)\.(css|js)$
^
- the beginning of the line
( )
- what is inside the brackets will separately fall into the variables $1, $2, .. $N
.
- any character
+
- determines the amount of what precedes it: "1 or more"
.+
- one or more of any characters
\.
- literally an ordinary point, point vulgaris, without special. values
\d
are a digit. \d+
one or more digits
(css|js)
- or "css" or "js"
$
- the end of the line
Thus, this regular expression will match, say, a string
/css/main.min.682375227.css
and replace it with a string without a number:
/css/main.min.css
Probably, this is how they deal with caching in the browser. In HTML, you can write with any number, and the browser will think it's something new. And the server will always give the same main.min.css
one that it has there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question