Some problems about the separation of front and back

Time:2021-7-21

nginx

  1. Set index.html not to be cached
    Because the projects are engineering packaged, every time the contract is awarded, except index. HTML, the suffixes of other files are with MD5 strings. In this case, index.html should not be cached in nginx to prevent the browser from accessing the old file, resulting in 404 script files
  2. History mode routing
    When the route adopts the history mode, nginx needs to configure the route try_ files $uri /index.html;
    Because the project has only one HTML, but every time you visit a path, you will look for the HTML in the corresponding path. If you can’t find it, you can ask him to find the HTML in the root directory

Browser‘s enter, F5, Ctrl + F5

Premise: nginx server does not make special configuration

enter

Cache-Control: max-age=0
Status Code: 304 Not Modified

Some problems about the separation of front and back

f5

Cache-Control: max-age=0
Status Code: 304 Not Modified

Some problems about the separation of front and back

ctrl+f5

Cache-Control: no-cache
Status Code: 200 OK

Some problems about the separation of front and back

Open the browser, enter the URL directly, and press enter
Without cache control, static resources cached on the hard disk will not initiate network requests

Status Code: 200 OK (from disk cache)

Some problems about the separation of front and back