Skip to content

Commit f7600d4

Browse files
authored
chat - disable cache for requests (microsoft#235673) (microsoft#235674)
1 parent 9e67a1d commit f7600d4

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/vs/base/parts/request/common/request.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ export interface IRequestOptions {
4545
data?: string;
4646
followRedirects?: number;
4747
proxyAuthorization?: string;
48+
/**
49+
* A signal to not cache the response. This may not
50+
* be supported in all implementations.
51+
*/
52+
disableCache?: boolean;
4853
}
4954

5055
export interface IRequestContext {

src/vs/base/parts/request/common/requestImpl.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ export async function request(options: IRequestOptions, token: CancellationToken
2121
]) : cancellation.signal;
2222

2323
try {
24-
const res = await fetch(options.url || '', {
24+
const fetchInit: RequestInit = {
2525
method: options.type || 'GET',
2626
headers: getRequestHeaders(options),
2727
body: options.data,
28-
signal,
29-
});
28+
signal
29+
};
30+
if (options.disableCache) {
31+
fetchInit.cache = 'no-store';
32+
}
33+
const res = await fetch(options.url || '', fetchInit);
3034
return {
3135
res: {
3236
statusCode: res.status,

src/vs/workbench/contrib/chat/browser/chatSetup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ class ChatSetupRequests extends Disposable {
541541
type,
542542
url,
543543
data: type === 'POST' ? JSON.stringify(body) : undefined,
544+
disableCache: true,
544545
headers: {
545546
'Authorization': `Bearer ${session.accessToken}`
546547
}

0 commit comments

Comments
 (0)