Skip to content

Commit

Permalink
docs: better cache docs
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Jan 3, 2024
1 parent 39c99dc commit 0562bd7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 11 deletions.
32 changes: 30 additions & 2 deletions lib/core/engine/command/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,34 @@ import intel from 'intel';
const log = intel.getLogger('browsertime.command.cache');
export class Cache {
constructor(browser, browserName, extensionServer, cdp) {
/**
* @private
*/
this.browser = browser;
/**
* @private
*/
this.browserName = browserName;
/**
* @private
*/
this.extensionServer = extensionServer;
/**
* @private
*/
this.cdp = cdp;
}

/**
* Clear the browser cache. Will clear browser cache and cookies.
* Clears the browser cache. This includes both cache and cookies.
*
* For Firefox, it uses the extensionServer setup with specific options.
* For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) commands.
* If the browser is not supported, logs an error message.
*
* @async
* @throws Will throw an error if the browser is not supported.
* @returns {Promise<void>} A promise that resolves when the cache and cookies are cleared.
*/
async clear() {
if (this.browserName === 'firefox') {
Expand All @@ -28,7 +48,15 @@ export class Cache {
}

/**
* Clear the browser cache but keep cookies.
* Clears the browser cache while keeping the cookies.
*
* For Firefox, it uses the extensionServer setup with specific options.
* For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) command to clear the cache.
* If the browser is not supported, logs an error message.
*
* @async
* @throws Will throw an error if the browser is not supported.
* @returns {Promise<void>} A promise that resolves when the cache is cleared but cookies are kept.
*/
async clearKeepCookies() {
if (this.browserName === 'firefox') {
Expand Down
44 changes: 36 additions & 8 deletions types/core/engine/command/cache.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
export class Cache {
constructor(browser: any, browserName: any, extensionServer: any, cdp: any);
browser: any;
browserName: any;
extensionServer: any;
cdp: any;
/**
* Clear the browser cache. Will clear browser cache and cookies.
* @private
*/
clear(): Promise<any>;
private browser;
/**
* Clear the browser cache but keep cookies.
* @private
*/
clearKeepCookies(): Promise<any>;
private browserName;
/**
* @private
*/
private extensionServer;
/**
* @private
*/
private cdp;
/**
* Clears the browser cache. This includes both cache and cookies.
*
* For Firefox, it uses the extensionServer setup with specific options.
* For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) commands.
* If the browser is not supported, logs an error message.
*
* @async
* @throws Will throw an error if the browser is not supported.
* @returns {Promise<void>} A promise that resolves when the cache and cookies are cleared.
*/
clear(): Promise<void>;
/**
* Clears the browser cache while keeping the cookies.
*
* For Firefox, it uses the extensionServer setup with specific options.
* For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) command to clear the cache.
* If the browser is not supported, logs an error message.
*
* @async
* @throws Will throw an error if the browser is not supported.
* @returns {Promise<void>} A promise that resolves when the cache is cleared but cookies are kept.
*/
clearKeepCookies(): Promise<void>;
}
//# sourceMappingURL=cache.d.ts.map
2 changes: 1 addition & 1 deletion types/core/engine/command/cache.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0562bd7

Please sign in to comment.