-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Much more robust API (may help a lot of people) #6
base: master
Are you sure you want to change the base?
Conversation
0) Returns proper HTML response codes 1) Much faster! (because it returns proper response codes browser doesn't wait!) 2) Can't crash the app by sending bad data (checks what you send it) 3) Makes sure the browser won't cache the data (problem solved) 4) If it can't update or delete an item you now will be notified properly
Christophe: LOVE your tutorials! I have learned quite a bit! I wanted to give back by improving your wines api a bit - 0) Returns proper HTML response codes 1) Much faster! (because it returns proper response codes browser doesn't wait...) 2) Can't crash the app by sending bad data (checks what you send it) 3) Makes sure the browser won't cache the data (problem solved) 4) If it can't update or delete an item you now will be notified properly 5) res.send changed to res.json
// if (req.session.userAuthenticated) { | ||
|
||
// We don't want the browser to cache the results | ||
res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just a watcher on this repo but wanted to comment that it's awesome that you've added no caching ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Ryan!
On Thu, Jan 24, 2013 at 8:45 PM, Ryan Regalado [email protected]:
In routes/wines.js:
exports.findById = function(req, res) {
+
- // At some point we may want to lock this api down!
- // If this is on the Internet someone could easily
- // steal, modify or delete your data! Need something like
- // this on our api (assuming we have people authenticate):
- // if (req.session.userAuthenticated) {
- // We don't want the browser to cache the results
- res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
I'm just a watcher on this repo but wanted to comment that it's awesome
that you've added no caching [image: ✨]—
Reply to this email directly or view it on GitHubhttps://github.com//pull/6/files#r2770226.
- Dan Stroot
Christophe - sorry I put this in the master branch - kind of new to all this. Cheers. |
Christophe: LOVE your tutorials! I have learned quite a bit! I wanted to give back by improving your wines api a bit -
doesn't wait...)
properly