Why Is Cache Causing You Issues?

September 08, 2020

Pen and Paper Analytical Data

It’s great for improving speed

Cache has been, at least for the last few years, a major component of websites and optimisation. I would love to say cache is ground-breaking for anyone wanting to have a website, however, it can very quickly spark hair pulling situations.

Cache enables visitors to experience quicker loading times, smoother animations and quicker data retrieval. In simple terms, using caching tools which are provided to you by your website hosting provider or by using plugins in WordPress can make your website faster and more user friendly.

Why it can be a headache

If you are someone who continuously puts work into your website and/or makes regular changes and additions, cache may start turning against you. Cache is data which is not stored as hard files within the server’s hard drives (or SSDs if you use a really good hosting company, sounds a lot like Cybrancee!), it usually gets stored in RAM for quick access. When you make changes to your website, you are updating the hard files stored on the server’s SSD, not the cache in RAM. This means that you may implement some changes but continue to see the old versions! But wait, there’s more. Your computer, phone, laptop or whatever device you are using is also storing cache! So you may eventually figure out that you need to clear the cache on the server, but you’ve now also got cache stored on your device. The cache on your device serves the same purpose, it helps you load websites quicker whilst using less internet (great when out and about using mobile data!).

Now, let’s go a step further and say you recently switched hosting providers (hopefully over to ours if you’re not already a customer!). The IP address will change (think of this as your home address changing when you move house, the IP address is like a home address, but just digital), your domain name remains the same, but this time, instead of dealing with server cache and cache stored on your computer to speed up loading times, you’ve now got DNS cache to deal with! DNS (Domain Name Server) is the backbone of domain names and accessing sites, I won’t go into detail as that can be for another blog, but DNS cache is something to look out for if your unable to access your website after a server change whilst other people can. A good check to see if DNS cache is the culprit is by switching your phone to use mobile data and then try and load the page.

As cache causes so many common issues (which aren’t issues, it’s just tech thinking it’s doing the right thing), IT Support Agents get the stereotype that all they say is “Have you cleared your cache”, and to be fair, they are right most of the time!

Using cache the right way

Now that I’ve finished grumbling about cache, if you’re wanting to help speed up your website, there are a few things you can do to implement a good caching system. WordPress makes this super easy, there are a multitude of plugins our there that can manage your cache

If you’re not using WordPress, don’t worry, there’s still an easy solution, it does require a bit of file changing though!

Whilst you’re here, it would be unfair for me to end it without spilling the quick guide on how to do it!

Access your website through FTP, cPanel or Plesk (we use Plesk!), head over to the Public_html folder and find your .htaccess file (If you are using cPanel, you’ll need to change the settings to show hidden files (dotfiles)). Once you have found it, open it up in your favourite editor. Add in the below to the bottom of your .htaccess file:

                                    
                                <IfModule mod_expires.c>
                                    ExpiresActive On
                                    ExpiresByType image/jpg "access 1 year"
                                    ExpiresByType image/jpeg "access 1 year"
                                    ExpiresByType image/gif "access 1 year"
                                    ExpiresByType image/png "access 1 year"
                                    ExpiresByType text/css "access 1 month"
                                    ExpiresByType text/html "access 1 month"
                                    ExpiresByType application/pdf "access 1 month"
                                    ExpiresByType text/x-javascript "access 1 month"
                                    ExpiresByType application/x-shockwave-flash "access 1 month"
                                    ExpiresByType image/x-icon "access 1 year"
                                    ExpiresDefault "access 1 month"
                                </IfModule>

                                <filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
                                    Header set Cache-Control "max-age=2592000, public"
                                </filesMatch>

                                AddOutputFilterByType DEFLATE text/plain
                                AddOutputFilterByType DEFLATE text/html
                                AddOutputFilterByType DEFLATE text/xml
                                AddOutputFilterByType DEFLATE text/css
                                AddOutputFilterByType DEFLATE application/xml
                                AddOutputFilterByType DEFLATE application/xhtml+xml
                                AddOutputFilterByType DEFLATE application/rss+xml
                                AddOutputFilterByType DEFLATE application/javascript
                                AddOutputFilterByType DEFLATE application/x-javascript
                                
                            

If you’re hosting your website with us, feel free to raise a case to us and we can help you out with adding this to your website!

FREE
Web Hosting

Get a Website Today!

SEE PACKAGE
Website illustration with leaf image

FREE
Web Hosting

Get a Website Today!

SEE PACKAGE
Website illustration with leaf image
Your subscription could not be saved. Please try again.
Thank you for subscribing, a confirmation email has been sent to your inbox.