How to improve your Magento store performance by using Fastly

How to improve your Magento store performance by using Fastly

Are you a  Magento store owner whos looking for a way to improve your user’s experience in terms of speed – try Fastly.

What is Fastly and why is it important for Magento?

Fastly is a modern CDN service – it uses SSD disks in their cache servers to ensure fast content access & a great cache hit ratio, it offers over 30 POP (point of presence) locations placed on strategic places all over the world (Asia, Europe, North & South America, Australia, New Zeland), it uses reverse proxying which means that the content is being fetched from your origin server as it’s requested and on top of that – they have greatly supported extensions for Magento 1 & Magento 2.

Benefits of using Fastly on your Magento store

  • Faster load times for web and mobile users
  • Better site stability in the event of traffic surges
  • Easy to configure with your Magento store

Installation guide for Magento 2

In this article, I will show you how to install and configure Fastly CDN extension for Magento 2.
To install the extension, just follow instructions from their Github repository.

You may choose between three installation methods – composer installation, installation through the Magento Marketplace and manual installation by downloading the zip file.

I will use composer as the installation method.

1. Open terminal \ console, go to your Magento installation directory and type these two commands in the following order:

composer config repositories.fastly-magento2 git "https://github.com/fastly/fastly-magento2.git"

Then:

composer require fastly/magento2

Once the installation is completed, enable the Fastly CDN module:

bin/magento module:enable Fastly_Cdn

Immediately after that, run the setup:upgrade command:

bin/magento setup:upgrade

And finally, clear the cache:

bin/magento cache:clean

You can read the more detailed step-by-step instructions here.

That’s it, you have successfully installed the Fastly CDN extension. Let’s move to configuration.

Configuration

In order to use the Fastly Cdn extension, you will have to register a free Fastly account.

Once you register and verify your account, login to Fastly:

Fastly wizard

You will see a welcome wizard with two input fields which you should fill with:

  • Your website domain for Fastly to use when routing requests
  • The hostname (or IP address) and port number for your origin server

On the next screen, Fastly is offering you to enable gzip, logging and health check of your origin – you can enable this later. Click continue.

On the final screen, you will have to point your CNAME to Fastly. Doing this, you will direct traffic from the Internet through Fastly instead of immediately through your store. You can read more here on how to achieve this.


Once you’ve finished with pointing your CNAME to Fastly, let’s configure Magento.

Login to you Magento admin and go to:
Stores > Configuration > Advanced > System

Under the Full page cache tab, untick the Use system value checkbox next to the Caching Application and choose Fastly CDN.

Click on Fastly Configuration tab and enter your Fastly Service ID* and Fastly API key**.

*To find out you Service ID, login to the Fastly dashboard, locate your Service name and click on the Show Service ID link.

**To find out your API key, while in the Fastly dashboard, select Account from the user menu and scroll way down to the bottom of the page. In the Account API Key area, click the Show button.

You can press the Test credentials button just to make sure that you have entered valid credentials.

If you have received a success message, press the Save Config button and clear cache by going to System > Cache Management.

Once you have cleared the cache, go back to Stores > Configuration > Advanced > System and click on the Fastly Configuration. The final step is to upload the VCL to Fastly. You can do this by pressing the Upload VCL to Fastly button.

The modal window will pop up, make sure that the Activate VCL after upload is ticked and press the Upload button in the top right corner:

Once the upload process is done, the modal window will automatically close and the success message will show:

That’s it, you have successfully configured your Magento store with the Fastly CDN.

Advanced configuration

You can configure advanced options by clicking the Advanced Configuration tab under the Fastly configuration. You have a detailed description under every option – read it and configure it according to your needs.

You can read more about advanced configuration here.

Purging

You can purge Fastly CDN content through the Magento admin by going to System > Cache Management. You can purge content by the following options:

  • Purge by content type
  • Purge by store
  • Purge a URL
  • Purge all

You can read more about purging here.

You made it all the way down here so you must have enjoyed this post! You may also like:

3 best open-source eCommerce platforms in 2021 Zrinka Antolovic
Zrinka Antolovic, | 8

3 best open-source eCommerce platforms in 2021

Introducing BrexitCart by Inchoo – a new cart abandonment solution Aron Stanic
Aron Stanic, | 1

Introducing BrexitCart by Inchoo – a new cart abandonment solution

Configure Origin shielding and timeout settings in Fastly Hrvoje Ivancic
, | 0

Configure Origin shielding and timeout settings in Fastly

10 comments

  1. Dear Hrvoje,
    Thank you for the great article. We are looking for the great tool which can improve stability and speed of our first developed e-shop. It seems that we are find right tool here. We wish find more interesting articles here in the future.

    1. I meant that after we configure CNAME to point www to nonssl.global.fastly.net.
      We cannot access our admin URL?

  2. Nice Post!
    I read your blog post and it completely provides CDN services information which is simple way increase Magento performance.

    Thanks for sharing!!

  3. Your post is very informative.
    You have mentioned full details about CDN services to upgrade our website to Magento 2.0.

  4. I Love your post. It is informative and provide complete knowledge of CDN services which makes easy to improve magento store performance.

    I will definitely use this on my next store.

    Thanks for sharing!!!

  5. This article is very helpful for improving the Magento performance. Thanks for sharing.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.