Skip to content
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

Allow options to bubble upstream, support 304s. #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joshwlewis
Copy link
Contributor

On a V1 model, when doing something like Comment.all(post, { cache: true }), $.ajax() doesn't get the cache option passed to it. This means we can't use the ETag/If-None-Match caching built into ajax on APIs that support it. There is also a ifModified option for $.ajax() with similar functionality that doesn't get sent up through RestModel V1.

Additionally, when an ETag is still valid, we don't need to update the cached response. In both V1 and V2, we now abort processing and updating in the case of 302 (not modified) responses.

@joshwlewis
Copy link
Contributor Author

@JackCA, can you take a look?


if (processedCache && jqXHR.status === 304) {
// Cache is valid, do nothing.
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we in danger of something chaining off of this with a null value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so... Line 433 doesn't have a return either. So the return value from 437 doesn't go anywhere.

@JackCA
Copy link
Collaborator

JackCA commented May 11, 2015

👍

@joshwlewis
Copy link
Contributor Author

Cool -- there is a small API change in the V2 ajax method. This should probably be a major version bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants