Skip to content

Commit

Permalink
fix: prevent dual cache revalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Mar 18, 2023
1 parent 62528f0 commit da3af4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AkteApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class AkteApp<TGlobalData = unknown> {

this.config = config;

debug("created with %o files", this.config.files.length);
debug("defined with %o files", this.config.files.length);

if (isCLI) {
runCLI(this as AkteApp);
Expand Down
2 changes: 1 addition & 1 deletion src/AkteFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class AkteFiles<
constructor(definition: FilesDefinition<TGlobalData, TParams, TData>) {
this.definition = definition;

debug("created %o", this.path);
debug("defined %o", this.path);
}

/** @internal Prefer {@link AkteApp.render} or use at your own risks. */
Expand Down
7 changes: 5 additions & 2 deletions src/vite/plugins/serverPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ export const serverPlugin = <TGlobalData>(
target: `http://${req.headers.host}/${options.cacheDir}/render`,
});

// Revalidate cache if cache was used
if (match.globalData || match.data) {
// Revalidate cache on non-fetch requests if cache was used
if (
req.headers["sec-fetch-dest"] === "empty" &&
(match.globalData || match.data)
) {
revalidateCache(match);
}
});
Expand Down

0 comments on commit da3af4e

Please sign in to comment.