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

How best to defeat browser caching when requesting Activity Profile #158

Open
uglycoyote opened this issue Sep 27, 2020 · 2 comments
Open

Comments

@uglycoyote
Copy link

I am trying to develop something where different users, running the xAPI package that I am developing, communicate information through a shared document using the Activity Profile. (a sort of a shared "leaderboard" for competition, similar to the Tetris sample from xAPI.com

I'm running into issues where, when calling retrieveActivityProfile, the response is returning Chrome's cached version of the response, rather than sending the response to the server.

I have tried to remedy this problem by adding extra headers

export const cacheDefeatHeaders = {
    'Cache-Control': 'no-cache, no-store, must-revalidate', 
    'Pragma': 'no-cache', 
    'Expires': '0'
};

and passing this in as the cfg.requestHeaders to the call. but that hasn't made a difference, and after reading more about those headers, I'm now under the impression that those are more supposed to be headers that the server includes in the response, in order to tell the client browser not to cache. I don't have control over the server's response though (it is a commercial LMS) so I cannot include the no-cache headers into the server's response.

It seems like the common way of defeating the cache from the client perspective is just to do something to ensure that the URL is different each time, such as including a timestamp into the query string. But I'm not sure if TinCanJS provides a way to do this from the retrieveActivityProfile query.

I can see that under the hood, the sendRequest function that retrieveActivityProfile calls allows for passing an arbitrary collection of URL query parameters, but at the top level call, there doesn't appear to be any way to pass extra parameters or otherwise configure retrieveActivityProfile to add something like a timestamp into the URL.

Is there a recommended approach in TinCanJS to force the request to go through to the server and not use the browser's local cached version?

@garemoko
Copy link
Contributor

I'm curious if you're seeing this behaviour with other LRSs?

@uglycoyote
Copy link
Author

@garemoko I'm only really using the one LRS (CornerStone OnDemand) so I don't know whether it's a problem with others. I think it's entirely just a question of what headers are served up with the responses to the queries.

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

No branches or pull requests

2 participants