Configure the server so that the user's browser caches data. Then, when the user first visits the resource, saving some elements of the site (images, CSS and JS files) will be automatic. The next time, the browser will not download them, and therefore will not waste time on this.
But this method allows you to make loading faster only for repeat visits to the site.
How to enable caching?
Use the Apache web server headers module, designed loadrunner protocol list to control and change the headers of HTTP requests and HTTP responses. The browser downloads data that rarely changes from the server to the local cache, and when visiting the resource, it downloads them from the cache. You can also cache files of certain types for the required period, after which they will be downloaded again from the server.
This can be done in this way:
Specify the necessary file extensions in the FilesMatch construct, where the Cache-Control header and the max-age variable will be set for them. This variable will be used to specify the storage duration of files in seconds. Files that do not need to be cached can simply be omitted from the list.
It is also possible to set a ban on file caching. To do this, the code below can be added to .htachess, specifying in advance which file types should not be cached:
<FilesMatch ".(pl|php|cgi|fcgi|scgi)$">
Header unset Cache-Control
</FilesMatch>
You also have the ability to control caching using the expires module. It controls how the browser sets HTTP headers for caching. Specify the storage period based on the time, the last modification to the file, or the client access time.
For example, like this:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 2 month"
Or like this:
ExpiresByType text/html “access plus 2 month 14 days 7 hours”
ExpiresByType image/gif “modification plus 8 hours 3 minutes”
Reduce CSS and JavaScript code size
Using special services that simplify JavaScript and CSS, unnecessary characters (spaces, comments) are removed from the code. Due to this, the code loads faster. For speed, these services can be more useful than standard gzip compression. Google recommends inserting small CSS files directly into the HTML document.
Download a useful document on the topic:
Checklist: How to Achieve Your Goals in Negotiations with Clients
To reduce the code size, you can use, for example, CSS Drive, CSS Compressor services. CSS files should be placed at the beginning of the page, and JS files at the end.
By placing CSS files in the header, page rendering becomes gradual, which creates a favorable impression of the Internet resource.
If JS files are placed at the bottom of the page, the browser can load the content first and then deal with the scripts.
Enable data caching
-
- Posts: 415
- Joined: Tue Jan 07, 2025 4:20 am