mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Set cache-control max-age: 0 for when downloading skins in the web client.
This way we'll still get 304 responses for 99% of skin fetches. Still not as ideal as the old method where they would be retrieved from the browser cache instead, but this way means skins changes show up instantly instead of after 1-3 hours. (this has been grumbled about quite a bit)
This commit is contained in:
parent
cef3db9fe7
commit
adf557bde4
1 changed files with 14 additions and 3 deletions
17
src/Http.c
17
src/Http.c
|
@ -382,9 +382,20 @@ static void Http_DownloadAsync(struct HttpRequest* req) {
|
|||
attr.requestDataSize = req->Size;
|
||||
}
|
||||
|
||||
/* TODO: Why does this break */
|
||||
/*static const char* headers[3] = { "cache-control", "max-age=0", NULL }; */
|
||||
/*attr.requestHeaders = headers; */
|
||||
/* Can't use this for all URLs, because cache-control isn't in allowed CORS headers */
|
||||
/* For example, if you try this with dropbox, you'll get a '404' with
|
||||
/* Access to XMLHttpRequest at 'https://dl.dropbox.com/s/a/a.zip' from
|
||||
/* origin 'http://www.classicube.net' has been blocked by CORS policy:
|
||||
/* Response to preflight request doesn't pass access control check:
|
||||
/* Redirect is not allowed for a preflight request. */
|
||||
/* printed to console. But this is still used for skins, that way when users change */
|
||||
/* their skins, the change shows up instantly. But 99% of the time we'll get a 304 */
|
||||
/* response and can avoid downloading the whole skin over and over. */
|
||||
if (urlStr[0] == '/') {
|
||||
static const char* const headers[3] = { "cache-control", "max-age=0", NULL };
|
||||
attr.requestHeaders = headers;
|
||||
}
|
||||
|
||||
attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY;
|
||||
attr.onsuccess = Http_FinishedAsync;
|
||||
attr.onerror = Http_FinishedAsync;
|
||||
|
|
Loading…
Reference in a new issue