Is your WordPress site taking too long to load? Did you know that a slow website will affect your search engine optimization and user experience?
There are several different ways to speed up your site besides using plugins. One way is to use the browser cache and the other is to compress your files.
Both can be done by modifying and optimizing the .htaccess file.
What is browser cache?
When someone visits your site, there are files that are downloaded and stored in a temporary location.
File types include all documents that make up your website, such as HTML files, images, JavaScript, and CSS. The browser cache is a temporary location for downloaded files.
When the cache is full, it takes up too much space on the visitor’s computer. As a result, the browser is slow and the website takes too long to load.
– /
Fortunately, there is a way to fix this by editing the .htaccess file.
What to do first
Before you start editing your .htaccess file, take the following precautions:
- Always back up your WordPress .htaccess file before modifying it.
- Disable any WordPress plugins you may be using.
- Test your site’s speed before making any changes to your .htaccess file to get a baseline. You can use GTmatrix, Pingdom, or Google PageSpeed ??Insights.
You are now ready to use the code from the .htaccess file to tell your WordPress installation to cache static files longer for repeat visitors to your site. You can use cPanel or FTP. See instructions below for each.
Once you have access to the .htaccess file, use the additional instructions to make your changes.
Using cPanel
Log into the cPanel of your site. This can usually be done by typing yourdomain.com/cPanel in your web browser.
Log in using the username and password you provided when installing WordPress on your domain. Once logged in, find and click File Manager.
Your .htaccess file is located in the root folder. The period before the filename indicates that this is a hidden file in your WordPress installation. Be sure to check the box next to “Show hidden files”.
You must make a copy of your file before editing it, because if you make a mistake, you could destroy your site. To make a copy, click on .htaccess and select it. To save a copy, click the download button located in the top menu.
Once you’ve made your copy, you are now ready to edit the file. In the cPanel file manager, right-click on the .htaccess file and select Edit.
Using FTP
You can also edit the .htaccess file using your FTP client. One of the popular FTP clients is FileZilla, which is used in the example below.
Start by opening your FTP client and enter your host. This is usually your domain address, your username and password. If you don’t know what this is, check with your web host.
Use the following steps to access, copy and edit the .htaccess file:
- Go to the root directory.
- Find the .htaccess file, make a copy and drag it to your desktop.
- Keep a copy of the original and edit another copy in case you need to restore the original.
- Use an editor such as Notepad to edit the file.
- When you’re done editing, upload the file to your root directory.
If you are wrong, your site will not work. To fix this, download the backup file.
You are now ready to make changes to your .htaccess file to speed up your WordPress site.
Zip your files with Gzip
Gzip compression makes your files smaller and helps them load faster. Adding the below code to your .htaccess file (under the current code) with gzip compresses your CSS, HTML and PHP files.
Don’t forget to click “Save Changes”.
Browser caching
When someone visits your website, the browser they are using downloads all the files associated with the page they are accessing.
Using browser cache means you only want to download the files you need, not unnecessary resources. This is usually the design and style of your page, and sometimes includes JavaScript functionality as well.
When you use the browser cache, you tell the server to ignore the parts of your web page that were previously loaded for repeat visitors.
To edit the .htaccess file, find it and make two copies in the same way as you did when compressing files as described above using an FTP client or cPanel.
Keep a copy of your original .htaccess file in case you have problems with the changes. Edit another copy.
Add the following code below the current content of your .htaccess file:
Don’t forget to click “Save” to save the additions to your file.
Compressing files and using the browser cache will dramatically reduce your web page load times. This will help your site rank higher in search and improve user experience. Nobody wants to wait more than a few seconds for a page to load.
–