Recently, I ran an experiment to test the performance of my WordPress website on a shared hosting with Bluehost vs Firebase and in this post I want to share a detailed analysis on how Firebase wins at speed and security. In fact, you are reading this article while it’s hosted on Firebase.
I had two clear objectives with this experiment:
One was to figure out how to optimise the speed and security of my WordPress website and second was to try Firebase and get a sneak peek into cloud hosting environments.
Wait, what is Firebase?
I would not be surprised if this is the first question that comes to your mind. Firebase is a cloud platform by Google offering a range of products and one of the great features of this platform is that it also offers fast and secure web hosting for free. You also get:
- SSD-backed hosting at CDN edge servers
- Free SSL certificates for custom domains
- Quick and continuous deployment
So you might be thinking, “What does this have to do anything with WordPress?”. Well it turns out, WordPress is a great content management system but it has its challenges: (1) speed and (2) security, specially when hosted over shared hosting environment, and Firebase is a great solution to those challenges.
Why care about speed and security?
Performance is a critical factor that affects the user experience of your website and its taking a center stage with core web vitals which is a new set of essential metrics that Google will be using to rank your website based on its performance. It is therefore essential to host your site in an environment where the performance isn’t compromised.
The second critical factor that affects the health of your website is security and that’s a major concern for those who use WordPress to power their websites. According to stats by Kinsta:
- 41% of WordPress attacks are caused by bad hosting.
- 52% of WordPress vulnerabilities relate to WordPress plugins.
This means you need to be extra careful when it comes to choosing your hosting for WordPress or at least you need to put the right measures in place to make sure your site is not getting hacked or infected while you are not looking.
Firebase is great but there are limitations
Hosting your site on Firebase basically means you will be hosting your site for free on Google Cloud servers so you will get rock solid performance but there are limitations:
- Only static files allowed: This means that you can only host HTML, CSS or JS files on your servers and any other kind of executable files can’t be hosted on Firebase.
- Cap on data and bandwidth: On Firebase you can store up to 1GB of data and you get 10GB of bandwidth for free (which is a really good offer for cloud hosting)
- Technical learning curve: Before you jump into this make sure you are comfortable navigating filesystems using shell commands because Firebase has a technical learning curve.
Let’s also not ignore the downsides of these limitations.
The biggest downside of hosting your WordPress site on Firebase is that you won’t be able to use any server-side functionality e.g. having users log-in, running membership or e-commerce plugins, running widgets like popular posts etc so consider Firebase only when your focus is hosting a simple informational site with a focus on speed and security like a blog.
“Wait! but WordPress is powered by PHP and MySQL so how will I get WordPress to run on Firebase if it can only host static files?”.
Don’t worry we will get to that shortly.
There is a solution: Generating static files
“What?! Why would I want to generate static files from WordPress” seems like the obvious question at first but then you can’t really compare the performance of WordPress generated web page to plain old HTML files (the latter always wins!) so the obvious solution here was to figure out a way to generate static files with WordPress and host them on Firebase.
“Why not just get rid of WordPress completely?”
Getting rid of WordPress is one of the options too but then you would get into the hassle of managing a whole bundle of HTML files which can be hard to maintain and edit unless you are using some automated script, framework or content management system.
In my research I found that Hugo is a good option. Hugo is one of the most popular open-source static site generators and its claim to fame is Smashing Magazine which moved from WordPress to Hugo last year.
I will be honest, I tried it, and its really fast because in the end you basically get a bundle of HTML files that you can upload to your website but then again if you can do the same with WordPress using a plugin like WP2Static then why give up on the flexibility and functionality that WordPress has to offer.
Making Firebase and WordPress work together
This was the tricky bit in the whole experiment since I wanted the flexibility and power of WordPress while not compromising on speed and security so eventually I came up with the solution of hosting WordPress on a sub-domain with my shared hosting while pointing the root domain to Firebase hosting so I can edit my blog using WordPress and then generate static files that can be pushed to Firebase for amazing performance.
After giving this a few tries and breaking a few things here and there I was about to figure out the right recipe to make this happen.
The right recipe is simple: move WordPress to a sub-domain and then setup Firebase hosting on your root domain (needless to say please take a backup of your website before you attempt any of this)
First things first, please make sure you have setup your WordPress site on a shared hosting so that your DNS is pointed there and you have access to edit some of the entries.
Second, make sure your WordPress is installed on your sub-domain on your hosting. Moving WordPress to a sub-domain is a topic that has been covered quite a lot on the web so I am not going to get into that but I am going to show you some steps on how to setup Firebase hosting on your root domain and then connect it with WordPress.
Now we get to the exciting part of setting up Firebase. Brace yourself, this is the part where we are going to rely on our love for technology.
1. Go to Firebase console and sign in with your Gmail ID!
2. Add a new project and follow the onscreen instructions
3. Since we are concerned with only hosting right now so you ignore the rest of the Firebase programs and just go to Hosting.
4. Follow the on-screen instructions to setup Firebase Hosting or follow this tutorial.
5. Add custom domain. Remember that this is the same domain which has WordPress hosted on its sub-domain.
6. Follow the on-screen instructions to verify your domain ownership by adding TXT records on your shared host via the DNS edit setting. Once verified you can add A-record entries to your DNS that point to Firebase to go live.
At this point you should have a WordPress installed on your sub-domain and Firebase hosted on your root domain.
The quick and easy way to publish changes from your WordPress to Firebase is to login to WordPress and make edits as you wish and then once you are ready to publish, export static files using WP2Static and push them to your root domain using the firebase deploy command.
Since this requires manual export and upload this might not be a convenient option if you have very active site on which you add content every day but if you are my sort of person who publishes updates to the blog once every few weeks then this is the best way to host your website without compromising on speed and security.
Firebase: The winner in speed and security
Well you may still ask, “why should I go through so much trouble?” and the answer is speed and security.
It is increasingly becoming difficult to manage WordPress on shared hosting because of the increasing amount of malware that targets WordPress websites and usually it takes a simple outdated plugin to cause your site to be compromised by a bad actor like a hacker or a backdoor.
Moving WordPress to a static form gives you the freedom of not having to worry about your site’s security and then there’s the speed factor which is just cherry on top. The screen below should give you an idea about the increase in performance of the same site on BlueHost vs Firebase (tested with Google Lighthouse)
Interestingly as soon as I uploaded this article to the blog and pushed it to Firebase I had a small plugin conflict on the sub-domain where WordPress is installed and the site went down but the main site on Firebase wasn’t affected at all.
This was a good reminder why moving the site to Firebase was a great experiment not just in terms of speed and security but also for the integrity and uptime of the website.