It takes too long for browsers to access the web project page CSS and JS files to load. What is the reason?

Server environment: Ali Cloud centos7.4 nginx1.14 php7.2 mysql5.7

there is no problem for the project to run locally and load quickly, but after deployment to the server, access to the web project on the server, when the browser clears the cache, some js files on the page will be loaded for 40s, and the second visit will be soon, and then clearing the cache will load for a long time. Is it the reason for not compressing the CSS and js files? But the local code is the same, and it loads very quickly.

Jun.05,2022

first of all, tell me why it is fast locally and slow on Aliyun. The
request actually jumps between multiple switches on the network before it reaches the destination server.
1. Start the service locally and visit the page locally. This route is already very short. If you set up a server abroad and set up a server at home, if you have the same bandwidth, the request for data is generally faster at home. (the solution is: CDN service, Ali should also have)
2. The bandwidth of Ali Cloud service may be relatively small, which is also the reason that affects the speed of requests. (this solution: increase the bandwidth. The bandwidth of Ali CVM is the same as the number of CPU cores and memory, but the price is not clear.)

3, also, several files that load slowly are larger, and the two files that take a long time to load, one 3.5m, one 1.3m.
can be compressed first, then split according to the business, and lazy loading can be implemented. In this way, the loading speed may be faster.

the second load is faster, because of the cache of local js and css, and the page uses cached js and css files. After clearing, these files will be reloaded, which will naturally be much slower.


your bundle is too big. The second access is fast because it is taken from the local cache, so it is fast; the first time is to request your server, but also need to download, so slow. Suggestion:

  1. Code Compression: you have to compress the code, and I wonder if you packed the source-map, too?
  2. split bundle: split the necessary ones and load others asynchronously
  3. Server opens gzip

but the first stylesheet 300KB took 8 seconds, which is abnormal and too slow. You have to investigate for yourself


static under compression,
enable static cache cache expires 30d again
suggest


to compress static files such as css js.


take apart the large js file first!


has the landlord solved it? The same problem occurs. Internet access is fast, but access through dedicated lines is slow

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be88a5-3115b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be88a5-3115b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?