Today I learned about...
backend
Back to all tags
cloudflare status headers
So I’ve been trying to add in some cache-control
headers to my remix site and
I’m using cloudflare as my CDN.
In order to determine if the cache is being hit, cloudflare adds a
cf-cache-status
header to the response. You can find out more about it in the
below blog post!
express-middleware
Express middleware is broken up into different types based on the number of arguments your middleware function takes. A middleware function that takes 4 arguments is classified as “error handling middleware”, and will only get called if an error occurs.
Model vs Controller
After a brief conversation with Darnell, TIL that a controller should only be concerned with the processing of a request. Database logic etc. should live in the Model.
I’m such a noob 😆
Hypermedia 🤔
In the Rest maturity model, Hypermedia is considered to be the most mature — the highest level.
- The swamp of Pox (XML)
- Resources
- HTTP Verbs
- Hypermedia
In a nutshell, Hypermedia has REST endpoints expose links to other related data.
For instance, if there was an endpoint that existed to fetch all the products in
a particular catalog, each product resource in the payload would have a _links
property that had attributes that would allow users of the API via self
to
navigate to the respected product. Just by visiting products, I’d have a way of
getting to a specific product without having to store the API endpoint in my
source code; the initial API call would prove it to me.
{
"_embedded": {
"products": [
{
"title": "Navy blue stone wash jeans",
"seller": "Revtown Jeans",
"_links": {
"self": {
"href": "/products/42"
}
}
}
// more products ...
]
}
}
A taste of Node
Node is super useful for doing high throughput low latency I/O tasks! Here’s a diagram that roughly describes how Node works (I omitted libuv but you can bet it’s there):
Server/A machine World/Another machine
+-----------------------------------------------+ +-------------+
| +-------------+ | | |
| |JS | | | |
| | | +--------------> |
| | | | | |
| | | | | |
| | | | +-----+-------+
| +---+--^------+ | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| +--v--+------------+ +------------------+ | |
| |Node (C++) | |OSS | | |
| | | | | | |
| | <--+ | | |
| | +--> | | |
| | | | | |<-------------------+
| | | | | |
| +------------------+ +------------------+ |
| |
+-----------------------------------------------+