Xrm.Tools.CRMWebAPI icon indicating copy to clipboard operation
Xrm.Tools.CRMWebAPI copied to clipboard

Status of cached files is excluded

Open ghost opened this issue 8 years ago • 9 comments

Status 304 is excluded for XMLHttpRequests. This will give an error when retrieving a cached file.

ghost avatar Oct 10 '16 12:10 ghost

Currently we aren't supporting the If-Match yet on a Get to support checking for a change - I assume that is what you are after? Can we change the title of this to "Support conditional retrievals" I would like to see this added in a future update

davidyack avatar Oct 10 '16 14:10 davidyack

I'm refering to this. you check in boundries of 200-299 but 304 for cached data would be ok as well.

req.onreadystatechange = function () {
            if (this.readyState == 4 /* complete */ ) {
                req.onreadystatechange = null;
                if ((this.status >= 200) && (this.status < 300)) {
                    callback(false, {
                        'response': this.response,
                        'headers': self.parseResponseHeaders(this.getAllResponseHeaders())
                    });
                } else {
                    callback(true, this)
                }
            }
        };

ghost avatar Oct 10 '16 14:10 ghost

Yes, right now I don't believe there a way we can encounter a 304 until we expose a way to do conditional retrievals - So agree when we add logic to support that we will need to expand to support 304 being returned

re - http://docs.oasis-open.org/odata/odata/v4.0/os/part1-protocol/odata-v4.0-os-part1-protocol.html#_Toc372793647

davidyack avatar Oct 10 '16 14:10 davidyack

But what if cache control is added in the response header? like Cache-Control:public, then the browser could cache.

ghost avatar Oct 10 '16 14:10 ghost

That is a good question I've not seen anything one way or the other - have you seen something that would indicate that would also return a 304, seems like that would conflict with the ability to do the conditional retrieval check if it interfered no?

davidyack avatar Oct 10 '16 14:10 davidyack

If you have the devtools open and watch the status of for example webresources they will turn to 304 if you reload sometimes. But don't forget to uncheck "disable cache if devtools are open" IE and chrome behave differently of course. Some elements have cache control public some have private some an etag it is not very consistant.

ghost avatar Oct 10 '16 14:10 ghost

Yeah I agree the web resources or any JS file etc will be impacted, but have you seen this on a Web API get request? Thx Dave

davidyack avatar Oct 10 '16 14:10 davidyack

well, yes, since I retrieve webresourse sometimes like that :D

ghost avatar Oct 10 '16 14:10 ghost

ok, will research a little more- either way should add 304 when we add conditional, just want to understand if there are other scenarios that will return it that need to be considered

thx

davidyack avatar Oct 10 '16 14:10 davidyack