-
Notifications
You must be signed in to change notification settings - Fork 921
Disable caching of Comments() action #112
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
Conversation
Adds an OutputCache attribute the the Comments() action, to prevent IE from aggressively caching the comments list. Otherwise IE will only show the comments that were returned in the first request unless you refresh the entire page.
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
public ActionResult Comments() | ||
{ | ||
return Json(_comments, JsonRequestBehavior.AllowGet); | ||
} | ||
``` | ||
|
||
And a corresponding route in `App_Start\RouteConfig.cs`: | ||
The `OutputCache` attribute is used here to prevent IE from caching the ajax request. IE tries to optimize things by assuming that identical requests will return identical responses. Subsequent calls to the Comments action will simply return the cached response from the first call, the result being that the comment list is never updated in IE as new comments are added. When designing a real world API, cache times of API requests should be considered more carefully. For this tutorial it is easiest to simply disable 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.
I think this description is a bit longer than it needs to be. I'd suggest changing this paragraph to:
The
OutputCache
attribute is used here to prevent browsers from caching the response. When designing a real world API, caching of API requests should be considered more carefully. For this tutorial it is easiest to simply disable caching.
Thank you! Just some minor comments :) 👍 |
Thanks. Your suggestions have been applied. |
Thank you! |
Disable caching of Comments() action
Adds an OutputCache attribute the the Comments() action, to prevent IE
from aggressively caching the comments list. Otherwise IE will only show
the comments that were returned in the first request unless you refresh
the entire page.
Fixes #111