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

Force Chrome to clear cache before opening a URL #56

Closed

Conversation

kyriakos
Copy link

No description provided.

@westy92
Copy link
Owner

westy92 commented Sep 16, 2017

Please make this an option, and not something that happens every time.

Add the property clearCache (boolean) to CreateOptions.

@@ -61,7 +61,9 @@ async function generate(html: string, options: CreateOptions): Promise<CreateRes
await throwIfCanceled(options);
const client = await CDP(options);
try {
const {Network} = client;
const {Page} = client;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine into:

const {Network, Page} = client;

const {Page} = client;
await Network.clearBrowserCache(); // Clear cache to force chrome to load a fresh copy
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for the added option (see PR comment):

if (options.clearCache) {
  await Network.clearBrowserCache();
}

Copy link
Owner

@westy92 westy92 Sep 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put an await throwIfCanceled(options); above this if check, too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. will do and update.

@codecov
Copy link

codecov bot commented Sep 16, 2017

Codecov Report

Merging #56 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #56   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines         108    110    +2     
  Branches       12     12           
=====================================
+ Hits          108    110    +2
Impacted Files Coverage Δ
src/index.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d8b63b...2359f10. Read the comment docs.

@TPoli TPoli mentioned this pull request Sep 28, 2017
@westy92
Copy link
Owner

westy92 commented Nov 6, 2017

Fixed in 652502f.

@westy92 westy92 closed this Nov 6, 2017
@westy92
Copy link
Owner

westy92 commented Nov 6, 2017

Usage:

const options: HtmlPdf.CreateOptions = {
  port,
  clearCache: true,
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants