This is a fast, compact, and straightforward web server designed to serve up single page web applications (SPAs) stored in a Redis database.
It's been awhile since I've had time to work on rediserve, but now I'm circling back to rework it for modern usage.
The new rediserve will be focused on building a platform through which developers can...
- Easily manage web app revisioning and caching π
- Host and serve web apps with the greatest possible performance and stability β‘
- Extend functionality to customize a Redis-based deployment platform π
Before we get to the technical stuff, let's talk about some of Rediserve's core features:
- None yet, sorry!
If you're still not convinced, you can read more about Rediserve below or check out the roadmap for future features.
Install with:
npm install -g rediserve
Note: first, make sure your app is ready to use with rediserve
Rediserve can be started from the command line:
rediserve --app my-ember-app --assets "https://s3.amazonaws.com/my-bucket/my-ember-app/"
Or you can load it as a dependency in your Node.js project to further customize its behavior:
Coming soon!
I think it's pretty good practice for every project (even if it's a small, side one!) to have to justify its own existence. So before you spend too much time reading about Rediserve and making your app compatible, let's talk about why this could be a good idea for you.
Rediserve was born out of one simple need: a need for speed. All joking aside, most developers who are familiar with Redis know that it is fast. As an in-memory data storage solution, Redis boasts all of the features of a full-fledged data platform while maintaining the speed of more "stripped down" solutions like memcached. Because of this, Redis has been used to speed up web applications in all kinds of unique and innovative ways.
Rediserve strives to take full advantage of the benefits offered by Redis to help you improve two vital aspects of your SPA:
One way that developers have taken advantage of Redis' speed is with page caching. The advantages of this are obvious: speed and scalability. Loading a page from a memory cache is orders of magnitude faster than loading from disk. Plus, typically, memory cache solutions can handle a much greater load than other storage methods. (Not to mention setting up an entire Redis cluster has become extremely cheap and easy to do.)
But Rediserve isn't designed or intended to just speed up the delivery of your SPA to the end-user. While a major focus of Rediserve is providing fast and simple page caching, an equally important purpose is making your development and deployment workflows faster.
After watching Luke Melia's 2014 talk at RailsConf, I realized how powerful Redis could be as a workflow tool as well as a performance tool. I may have found Luke's talk 2 years after he gave it, but it's certainly still relevant today. (Better late than never!) As development teams optimize their workflows to iterate frontend projects faster than ever, Redis' simple key/value storage system becomes increasingly attractive as an iteration management system. How exactly? I'm glad you asked! Most deployment strategies already implement some type of hashing strategy to mark different iterations of assets. By applying this strategy to your SPA's index.html
as well, you can serve multiple revisions at the same time! Still not making sense? That's okay, it is pretty confusing. Let's see how this would work with Redis:
Redis data store
Key | Value |
---|---|
my-app:index:current | a39nd129 |
my-app:index:a39nd129 | <html> <head> <title>Production</title> </head> ... </html> |
my-app:index:dn38au55 | <html> <head> <title>Revision dn38au55</title> </head> ... </html> |
As you can see, the default strategy is to store your index.html content as a value associated with a key named for your app and the index.html revision. (The revision tag is just a hash of your index.html content.) There is also an :index:current key that points to the current revision of index.html (the one you want to be served to users).
Right now, Rediserve is just a web server solution, so it doesn't handle deployment tasks. Therefore, Rediserve expects your index.html content to be stored in the above fashion. If you need to store your content in a different format, you can build a custom wrapper around Rediserve and use the open API.
For more information on how exactly this works and how Rediserve helps manage revisions, check out the usage in depth section. If you want to get your app set up to work with Rediserve right away, then simply continue reading!
Even though it is not (yet!) a full-featured deployment endpoint, Rediserve supports some revision management tasks out-of-the-box.
Automatic revision activation
If there is no :index:current key in your Redis database, Rediserve will automatically create one that points to the last added :index:revision record.
Example
Key | Value |
---|---|
my-app:index:a39nd129 | <html> <head> <title>Production</title> </head> ... </html> |
my-app:index:dn38au55 | <html> <head> <title>Revision dn38au55</title> </head> ... </html> |
would become
Key | Value |
---|---|
my-app:index:current | a39nd129 |
my-app:index:a39nd129 | <html> <head> <title>Production</title> </head> ... </html> |
my-app:index:dn38au55 | <html> <head> <title>Revision dn38au55</title> </head> ... </html> |
Rediserve takes advantage of a few other (popular, awesome, really well-written) node modules, most notably redis and express.
See the changelog for a list of previous changes
v0.3.0
- Operational and full-featured CLI
- Standalone web server (via express)
- Comprehensive docs
v0.4.0
- Revision management system available via API
- Built-in A/B testing mechanism
- Update docs, description, etc. for new feature set
> v0.4.0
- Extend revision management system and testing mechanics to CLI
- Deployment strategies for standalone SPAs
Nothing to show yet! Coming soon, though!
-
Open a pull request or an issue about what you want to implement / change. I'm always looking for help to move the project forward!
- I want this to be reliable and functional, so only submit thoroughly tested code!
-
The original author of Rediserve is Christian Gaetano
-
Matthew Ranney is the creator of the best Redis client for node that you can get your hands on
-
The team behind Express