Add REST API cache busting mechanism.#6948
Merged
eliorivero merged 3 commits intomasterfrom Apr 24, 2017
Merged
Conversation
enejb
reviewed
Apr 12, 2017
_inc/client/rest-api/index.js
Outdated
| } | ||
|
|
||
| function postRequest( route, body ) { | ||
| return fetch( addCacheBuster( route ), assign( {}, postParams, body ) ); |
Member
There was a problem hiding this comment.
I don't think it is necessary to cache bust POST requests. Browsers don't cache them by default.
enejb
reviewed
Apr 12, 2017
_inc/client/rest-api/index.js
Outdated
| } | ||
|
|
||
| function getRequest( route ) { | ||
| return fetch( addCacheBuster( route ), getParams ); |
Member
There was a problem hiding this comment.
It would be good to pass in the getParams explicitly into the function. So that the code is more readable.
enejb
reviewed
Apr 12, 2017
_inc/client/rest-api/index.js
Outdated
| : '', | ||
| args = query.split( '&' ); | ||
|
|
||
| args.push( '_rnd=' + ( 10e9 * Math.random() ) ); |
Member
There was a problem hiding this comment.
instead of doing generating a random math character. I would suggest we just use the current time in seconds or milliseconds with
var ddate = new Date();
var milliseconds = d.getTime();
also can we make the _rnd more explicit with something like _cacheBuster
Contributor
|
I like enej's suggestions, but otherwise this is a nice change 👍 |
…he busting on POST requests, fixed query param handling.
Contributor
Author
|
Thanks for the review @enejb, @dereksmart ! I have made changes to account for all the comments. |
Contributor
|
Changes look good! Let's get this in |
dereksmart
approved these changes
Apr 24, 2017
Contributor
|
Looks good! |
eliorivero
pushed a commit
that referenced
this pull request
Apr 25, 2017
* Changelog: initial commit for 4.9 release. * Changelog: add #6929 * Changelog: move old changelogs to changelog.txt * Readme: restore deleted release post link. The post is now live. * Changelog: add #6853 * Changelog: add #6856 * Changelog: add #6857 * Changelog: add #6884 * Changelog: add #6885 * Changelog: add #6892 * Changelog: add #6894 * Changelog: add #6898 * Changelog: add #6899 * Changelog: add #6900 * Changelog: add #6909 * Changelog: add #6927 * Changelog: add #6947 * Chagelog: add #6958 * Changelog: add #6961 * Changelog: add #6963 * Changelog: add #6965 * Changelog: add #6986 * Changelog: add #7000 * Changelog: add #7013 * Changelog: add #7015 * Changelog: add #7019 * Changelog: add #7028 * Changelog: add #6998 * Changelog: add #6999 * Changelog: add #7044 * Changelog: add #6881 * Changelog: add #6922 * Changelog: add #6940 * Changelog: add #6962 * Changelog: add #6942 * Changelog: add #6959 * Changelog: add #7018 * Changelog: add #6948 * Changelog: add #6657 * Changelog: add #7030 * Changelog: add #7048 * Changelog: add #7031 * Changelog: add #6990 * Changelog: add #6957 * Changelog: add #7027
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5217
Changes proposed in this Pull Request:
Testing instructions:
304 Not Modified. My guess is that it's because the server sends back theLast-Modifiedheader with the zero epoch time every time. If you can't reproduce it, try adding the header to API responses manually with this:Proposed changelog entry for your changes: