This site uses cookies and other tracking technologies to make possible your usage of the website, assist with navigation and your ability to provide feedback, analyse your use of our products and services, assist with our promotional and marketing efforts, and provide better user experience.

By using the website, you agree to our Privacy policy

Accept and continue

Report a bug

Cancel
112
How-to 8 min read July 29, 2019

How to enable and adjust site caching

To optimize the server and speed up the site, you should use file caching. This will not only speed up the display of content but also provide an uninterrupted work of the site and help to keep users.
The speed of the site depends on many factors and is one of the main features of its successful work. The slow loading of pages prevents the user from getting what he came for, and increases the bounce rate. Moreover, this indicator affects the position of the site in the list of search results, its traffic, and conversion.

What is caching?

When a user visits the site or opens the page, the computer, smartphone or other device sends a request to the server. This request is processed, returned and the browser displays the page on the screen. Whenever the user's device sends a request, the server must process this data in a new way to transfer all the elements.

If the server does not cope with processing a large amount of data, files may take a long time to load, and there may happen 5XX server errors. After that, the user simply closes the page, and we lose a potential visitor or customer.

Besides, the speed of loading pages is affected by the power of the device itself and the speed of the Internet connection. The performance of some old computers and mobile phones is not enough to quickly download content. Also, much depends on the speed and quality of the Internet connection.
Caching is the process by which the browser remembers the data that was transferred to the server for processing and later used to load the page.
Some elements of the site have the same structure, for example, the "Order" button or the navigation menu. They may appear on several pages of the site.

With the help of caching, the browser loads them once and saves them to the cache. The server won't have to re-process the same data each subsequent time and send it to the user. The browser has already "memorized" the necessary elements, and will display them almost immediately, without using additional traffic.

Types of caching

The cache can be created both from the user and in the server itself.
1
Browser caching. The user's device creates and saves a copy of the various elements of the site. These can be scripts, text, images, etc. When you open the page, the browser cache helps to load it all at times faster.
2
Server caching. All the data is stored on the server. It saves the results of queries, which helps to avoid reprocessing the same information from the user.

What to do with dynamic page elements

As anticipated, the site is periodically updated. Its content, images, design and other elements may vary. Caching is best suited for static site elements.

If the page element was cached and then changed, then at best, the browser will load an irrelevant version of the page that won't work correctly. At worst, the user will see an error on the screen.

It will need to clear the browser cache for the server to re-transmit the already updated data. Commonly, most users don't know how to do this.

Some sites are regularly updated and supplemented with new information. In this case, both the site owner and the user will constantly have to clean the cache. To avoid this, you can prescribe in the settings of individual items for caching, or conversely, eliminate the unnecessary ones.

How to enable site caching

There are many ways to enable and set up site caching.

We consider the fastest and easiest of them — caching using the .htaccess file (used if the server is running Apache). It's possible to write the desired period of caching, select individual items, or simply disable it. Moreover, you can code not only caching, but also other functions of the site in it.

The best way to work with .htaccess is in the Sublime Text editor or any other equivalent. This will help to avoid mistakes and problems with the encoding.
1
Find the .htaccess file in the root directory of the hosting. Open it with Sublime Text 3.
Adjusting cache in htaccess using Sublime text
Unless there is any, then you need to create it manually. To do this, open the software and write the following lines:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType application/javascript "access plus 5 days"
ExpiresByType text/javascript "access plus 5 days"
ExpiresByType text/css "access plus 5 days"
ExpiresByType image/gif "access plus 5 days"
ExpiresByType image/jpeg "access plus 5 days"
ExpiresByType image/png "access plus 5 days"
</IfModule>
In Sublime Text 3, the code should look like the following:
Caching in htaccess file
In our case, the cache period is 5 days (access plus 5 days). You can write any other number there, and instead of days, specify seconds, minutes, hours, weeks, months, etc. Duration should be chosen depending on the intensity of the site update, niche features and caching goals.

You can specify an absolute time limit (caching depends on the elapsed time) or relative (caching depends on the user's last visit).

It works both for all files, and the single ones. You can also add new or remove unnecessary items.
2
Save the file. You can do this on your computer, and then transfer it to the root folder of the site, or immediately save it to a directory. The main thing is to correctly name the file (.htaccess — with a dot in front). We recommend that you always keep a backup of your source file.
htaccess file saving
If you are creating the code without using the program, then simply transfer the text document to the root folder.

In various CMS, for example, WordPress, caching can be enabled using special plug-ins. All popular engines have similar solutions.

Conclusion

Site owners invest a lot of money to promote their resource in the TOP of the issue, raise a bit of capital to accelerate its work and improve the technical base of the server.

Website caching is one of the most effective ways to speed up the loading of pages. You can set up server or browser caching on your own absolutely for free. This doesn't take much time as it seems.

This article is a part of Serpstat's Checklist tool
Checklist at Serpstat
Checklist is a ready-to-do list that helps to keep reporting of the work progress on a specific project. The tool contains templates with an extensive list of project development parameters where you can also add your own items and plans.
Try Checklist now

Learn how to get the most out of Serpstat

Want to get a personal demo, trial period or bunch of successful use cases?

Send a request and our expert will contact you ;)

Rate the article on a five-point scale

The article has already been rated by 0 people on average out of 5
Found an error? Select it and press Ctrl + Enter to tell us

Share this article with your friends

Sign In Free Sign Up

You’ve reached your query limit.

Or email
Forgot password?
Or email
Back To Login

Don’t worry! Just fill in your email and we’ll send over your password.

Are you sure?

Awesome!

To complete your registration you need to enter your phone number

Back

We sent confirmation code to your phone number

Your phone Resend code Queries left

Something went wrong.

Contact our support team
Or confirm the registration using the Telegram bot Follow this link
Please pick the project to work on

Personal demonstration

Serpstat is all about saving time, and we want to save yours! One of our specialists will contact you and discuss options going forward.

These may include a personal demonstration, a trial period, comprehensive training articles & webinar recordings, and custom advice from a Serpstat specialist. It is our goal to make you feel comfortable while using Serpstat.

Name

Email

Phone

We are glad of your comment
Upgrade your plan

Upgrade your plan

Export is not available for your account. Please upgrade to Lite or higher to get access to the tool. Learn more

Sign Up Free

Спасибо, мы с вами свяжемся в ближайшее время

Invite
View Editing

E-mail
Message
Optional
E-mail
Message
Optional

You have run out of limits

You have reached the limit for the number of created projects. You cannot create new projects unless you increase the limits or delete existing projects.

I want more limits