admin Posted on 9:01 pm

How to take advantage of browser caching

While viewing web pages, the browser is forced to load various things. These include the CSS file, your logo, and other resources. In this case, browser caching only remembers already loaded resources. So it means that when you have a visitor to your website trying to get to another page, their browser is unlikely to try to find your CSS file or logo again. This is because the file already exists and will be “remembered” automatically. What follows next is that your pages will be able to load with greater speed.

You may have tested the speed of your web page and realized that you have to use browser caching; Here are tips to help you take advantage of it:

It is very important to add some code to the .htaccess file in your browser. In this case, it will go to the file manager of your web server. It’s also good to understand that the most important things on your site are controlled by the .htaccess file. Before you change this file, you need to understand what it really is. The following code should be added at the top of your .htaccess.

## CACHING EXPIRED ##

ExpiresActive On

EXPiresByType image/jpeg “1 year access”

ExpiresByType image/jpg “1 year access”

ExpiresBy Image/gif type “1 year access”

ExpiresByType image/png “1 year access”

ExpiresByType text/html “1 month access”

ExpiresByType text/css “access 1 month

ExpiresByType text/x-javascript “1 month access”

ExpiresByType/pdf application “1 month access”

ExpiresByType image/x-icon “1 year access”

ExpiresByType/x-showcase-flash app “1 month access”

expiresDefault “1 month access”

## CACHING EXPIRED ##

The next step is to make sure that your HTTP headers have been edited and that the expiration dates for certain files have been set again.

Try to find your .htaccess file from the root of your domain. This file is usually hidden, but you should be able to access it on FTP clients like CORE or Filezilla. You can also use notepad or any other text editor to make changes to your .htaccess file.

After editing the .htaccess file, you can now save it and update your page.

Best way to set different caching times for various file types

Looking at the code above, you will find that an expiration period of “1 month” or “1 year” is set. In most cases, this period is related to the different types of files. In the above code, for example, a .jpg file receives a 1-year cache. In case you need to make some changes and allow them a caching period of 1 month, the best way to achieve this is to simply replace “1 year” with “1 month”. Actually, it has been found that most of the web pages and blogs optimally use the above values.

You can set different expiration dates, depending on the website files. In a situation where you have your files regularly updated, you will be required to set an earlier expiration time on CSS files, among others. Having accomplished that, save the file in its current format and don’t change it to a text file. But if you are using some kind of CMS, there might be caching plugins or extensions.

It’s recommended that:

• For all static resources, you should be more active with your caching

• The minimum expiration period must be between 1 month and access +1 year

• Do not set your caching in advance for more than one year

Bail

When enabling browser caching, it is important that you take great care to ensure that parameters are not set too long for some files, as this may result in visitors not getting to the newer version of your website afterward. of the updates. If you hired a web designer to make changes to your website, it is likely that the changes have been made, although you may not be able to see them, as these elements have been cached in your browser.

Leave a Reply

Your email address will not be published. Required fields are marked *