Skip to content

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

Merged
merged 2 commits into from
Apr 12, 2015
Merged

Disable caching of Comments() action #112

merged 2 commits into from
Apr 12, 2015

Conversation

andersea
Copy link
Contributor

@andersea andersea commented Apr 6, 2015

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

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.
@facebook-github-bot
Copy link

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!

@facebook-github-bot
Copy link

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.
Copy link
Member

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.

@Daniel15
Copy link
Member

Thank you! Just some minor comments :) 👍

@andersea
Copy link
Contributor Author

Thanks. Your suggestions have been applied.

@Daniel15
Copy link
Member

Thank you!

Daniel15 added a commit that referenced this pull request Apr 12, 2015
Disable caching of Comments() action
@Daniel15 Daniel15 merged commit 5888655 into reactjs:master Apr 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tutorial change to fix IE caching of comment ajax response
3 participants