Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit 41fe3f4

Browse files
committed
caching
1 parent a852c40 commit 41fe3f4

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

_drafts/wework-com-is-going-static.markdown

+3-10
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,12 @@ There are many different ways to skin this cat, ranging from installing and conf
8181

8282
We found one host that met all of those requirements and more, and they are called [Netlify](https://www.netlify.com/). Never heard of them? Neither had we, but as a colleague of mine recently put it, "Netlify is like the developer whisperer". This team has put together an amazing service that handles SO much for you from a dev-ops persective of hosting static sites. And if there is a feature that is missing, they will bend over backwards to either implement it for you, or help you figure out a solution. I can sit here and sing their praises all day long, but its probably best if I explained a bit about how they were able to help us with our migration to a static site and make the static verions of our site *2-3x faster*.
8383

84-
To get started, one of the first pages we decided to migrate over to static was our [`/locations`](https://www.wework.com/locations/) page. This page doesn't get a ton of traffic, but has dynamic content coming from our backend, so it seemed like a good place to start. Looking at the graph below you can see the downward trend (in the world of performance, downward trending graphs are usually a good thing) from the day we rolled it out. Our "server" response time is **1ms** compared to 150-200ms on other, non-static pages. There are still other things we can do to make it even more performant, but we are very pleased with the results so far.
84+
To get started, one of the first pages we decided to migrate over to static was our [`/locations`](https://www.wework.com/locations/) page. This page doesn't get a ton of traffic, but has dynamic content coming from our backend, so it seemed like a good place to start. Looking at the graph below you can see the downward trend (in the world of performance, downward trending graphs are usually a good thing) from the day we rolled it out.
8585

8686
![Performance graph of locations page](http://res.cloudinary.com/wework/image/upload/c_scale,f_auto,w_1000/v1448740493/engineering/locations-graph.png)
87+
<small>*Via [calibreapp.com](https://calibreapp.com/)*</small>
8788

88-
And here is a before and after from the Chrome inspector showing some impressive before and after numbers:
89-
90-
##### Before (non-static)
91-
![Locations - before](http://res.cloudinary.com/wework/image/upload/c_crop,f_auto,g_north_east,h_30,w_550/v1448908828/engineering/locations-before.png)
92-
93-
##### After (static)
94-
![Locations - after](http://res.cloudinary.com/wework/image/upload/c_crop,f_auto,g_north_east,h_30,w_550/v1448908829/engineering/locations-after.png)
95-
96-
One can argue that the same level of performance can be achieved using CDN or Edge Caching, and this is definitely true. And in fact, edge caching is one of the many features that Netlify offers. But properly setting up your application to take advantage of edge caching, and then knowing when to invalidate that cache deserves a blog article on its own. As the saying goes, "There are only two hard things in Computer Science: cache invalidation and naming things." We've decided that we wanted spend more of our time on naming things :-)
89+
One can argue that the same level of performance can be achieved using CDN or Edge Caching, and this is definitely true. And in fact, edge caching is one of the many features that Netlify offers. But properly setting up your application to take advantage of edge caching, and then knowing when to invalidate that cache deserves a blog article on its own. As the saying goes, *"There are only two hard things in Computer Science: cache invalidation and naming things."* We've decided to spend more of our time on naming things :-)
9790

9891
So how are we serving up traffic to `wework.com/locations/` from the static host and other pages from our current non-static host? It was as simple has modiftying some DNS settings to route all traffic through Netlify, [creating a `_redirects` file](https://www.netlify.com/docs/redirects) at the root of our very basic static site, with some rules about which URL's to pass through and which ones to handle. Netlify's proxy and rewrite is actually very intelligent in how it handles requests. If it finds the file, folder or resource locally in your folder structure, it will serve that up before it tries to proxy it. On our site, we have a catch-all rule that looks like this:
9992

0 commit comments

Comments
 (0)