How to optimize the files and resources of a website ?, Website file resource optimization
1. file merging (to reduce http requests): When css sprites is used to merge images, small icons and small images are often used to beautify a website, but unfortunately these small images occupy a large number of HTTP requests, therefore, sprites can be used to merge all images into one image. You can use related tools to merge images online or in ps.
2. Use CDN (Content Delivery Network) acceleration to reduce the communication distance.
3. Add the Expire/Cache-Control header to use the Cache.
4. Enable Gzip compression.
JavaScript and css compression can be performed through dynamic scripts on the server, or the apache server can be used in the root directory of the website. add the following code to htaccess: AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/json
Header append Vary Accept-Encoding
This Code indicates that the compression module of the server is called to perform GZIP compression before the above files are output. After gzip compression, all files should be able to reduce the volume by more than 30%. Especially for blogs that use a large number of js resources, the speed can be improved a lot after gzip escort.
5. Place css on the top of the page.
6. Place the script at the bottom of the page.
7. Avoid using expressions in css.
8. Place css and js in external files.
9. Reduce DNS queries.
10. File compression: Minimize css and js and reduce the file size.
11. Avoid redirection.
12. Remove duplicate scripts.
13. Configure the object tag ETag.
14. Use AJAX cache to load and update website content in batches.