Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(isr): add compression (#1755) #1768

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

Open
wants to merge 42 commits into
base: main
Choose a base branch
Loading
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ba1cbbe
chore(isr): update CacheHandler and IsrServiceInterface typings
maxisam Aug 20, 2024
f7755ac
refactor: fix eslint issues
maxisam Aug 20, 2024
0af4f56
fix(isr): filter urlsOnHold by cacheKey instead of url
maxisam Aug 20, 2024
244bff7
feat: add allowed query params options #1743
maxisam Aug 22, 2024
50643b3
feat: handle query string for filesystem cache #1690
maxisam Aug 22, 2024
9dc5a70
fix(isr): in memory cache handler should use extends #1736
maxisam Aug 22, 2024
76aa916
Merge branch 'fix/instanceof' into dev
maxisam Aug 23, 2024
fcb59b2
Merge branch 'refactor/es-lint' into dev
maxisam Aug 23, 2024
cc19ee3
Merge branch 'feat/allowed-query-params' into dev
maxisam Aug 23, 2024
c37269b
refactor(isr): rename CacheRegeneration to CacheGeneration
maxisam Aug 23, 2024
039f09c
refactor(isr): rename CacheRegeneration to CacheGeneration
maxisam Aug 23, 2024
c95d1c6
fix(isr): handle modifyGeneratedHtml behavior consistantly #1758
maxisam Aug 29, 2024
e7ed6a5
Merge branch 'main' into dev
maxisam Aug 29, 2024
cb0261a
refactor(isr): use modifyGeneratedHtml instead
maxisam Aug 29, 2024
2dd9551
feat(isr): update the example to show modifyGeneratedHtml usage
maxisam Aug 29, 2024
9f4f0cd
Merge branch 'main' into feat/callback-cachemsg
maxisam Aug 29, 2024
5b7603e
Merge pull request #2 from maxisam/feat/consolidate-cache-generation
maxisam Aug 29, 2024
2c88c4f
feat(isr): add non-blocking-render option
maxisam Aug 29, 2024
dcc61f9
feat(isr): add background revalidation option
maxisam Aug 29, 2024
fe0bac2
feat(isr): enable background revalidation and non-blocking render
maxisam Aug 29, 2024
a88b5ca
Merge pull request #3 from maxisam/feat/response-first
maxisam Aug 29, 2024
2ae8857
feat(isr): add compression #1755
maxisam Aug 30, 2024
85b0dc3
chore(isr): rename HTML compression method
maxisam Aug 30, 2024
bdcc48b
Merge pull request #4 from maxisam/feat/compression
maxisam Aug 30, 2024
cd5c42d
Merge pull request #5 from maxisam/feat/compression
maxisam Aug 30, 2024
68f1d59
Merge branch 'main' into dev
maxisam Sep 3, 2024
a2192db
fix: merging issue
maxisam Sep 3, 2024
9ef7463
feat(isr): add compression
maxisam Sep 3, 2024
bb74688
fix(isr): fix eslint issue
maxisam Sep 3, 2024
d32eaf5
Merge pull request #8 from maxisam/chore/lint
maxisam Sep 5, 2024
0960536
Merge branch 'dev' into compress-new
maxisam Sep 5, 2024
55a7609
Merge branch 'main' into compress-new
maxisam Sep 18, 2024
d910520
chore: update yarn lock
maxisam Sep 18, 2024
b6f90a1
fix: format
maxisam Sep 19, 2024
ce45c32
feat: let cache handler handle cache html either buffer or string
maxisam Oct 7, 2024
65b0381
docs: how to use buffer in redis and compressHtml callback
maxisam Oct 7, 2024
7e8512b
docs(isr): add compression support for caching
maxisam Oct 16, 2024
28b86d2
Merge branch 'main' into compress-new
maxisam Nov 24, 2024
6c7670b
Merge branch 'main' into compress-new
maxisam Nov 24, 2024
f7fb152
refactor(isr): standardize terminology from 'route' to 'cacheKey'
maxisam Nov 27, 2024
bd14b62
docs(isr): update CacheHandler API doc
maxisam Nov 27, 2024
e08dd51
docs: revert
maxisam Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(isr): standardize terminology from 'route' to 'cacheKey'
  • Loading branch information
maxisam committed Nov 27, 2024
commit f7fb152d2214f809cced3d253ba8bc3685d7b4f5
32 changes: 18 additions & 14 deletions 32 libs/isr/server/src/cache-handlers/filesystem-cache-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class FileSystemCacheHandler extends CacheHandler {
})
.catch((err) => {
reject(
`Error: 💥 Cannot read cache file for route ${cacheKey}: ${cachedMeta.htmlFilePath}, ${err}`,
`Error: 💥 Cannot read cache file for cacheKey ${cacheKey}: ${cachedMeta.htmlFilePath}, ${err}`,
);
});
} else {
Expand All @@ -104,23 +104,23 @@ export class FileSystemCacheHandler extends CacheHandler {

delete(cacheKey: string): Promise<boolean> {
return new Promise((resolve, reject) => {
const cacheMeta = this.cache.get(cacheKey);
const cachedMeta = this.cache.get(cacheKey);

if (cacheMeta) {
fs.unlink(cacheMeta.htmlFilePath, (err) => {
if (cachedMeta) {
fs.unlink(cachedMeta.htmlFilePath, (err) => {
if (err) {
reject(
'Error: 💥 Cannot delete cache file for route ' +
'Error: 💥 Cannot delete cache file for cacheKey ' +
cacheKey +
`: ${cacheMeta.htmlFilePath}`,
`: ${cachedMeta.htmlFilePath}`,
);
} else {
this.cache.delete(cacheKey);
resolve(true);
}
});
} else {
reject(`Error: 💥 CacheKey: ${cacheKey} is not cached.`);
reject(`Error: 💥 cacheKey: ${cacheKey} is not cached.`);
}
});
}
Expand Down Expand Up @@ -184,7 +184,7 @@ export class FileSystemCacheHandler extends CacheHandler {
isBuffer: false,
});

console.log('The request was stored in cache! Route: ', cacheKey);
console.log('The request was stored in cache! cacheKey: ', cacheKey);
}
}

Expand Down Expand Up @@ -222,7 +222,9 @@ export class FileSystemCacheHandler extends CacheHandler {
}
}
} catch (err) {
console.error('ERROR! 💥 ! Cannot read folder: ' + folderPath);
console.error(
`ERROR! 💥 ! Cannot read folder: ${folderPath}, err: ${err instanceof Error ? err.message : ''}`,
);
}

for (const { path } of pathsToCache) {
Expand Down Expand Up @@ -316,7 +318,9 @@ function findIndexHtmlFilesRecursively(
});
} catch (err) {
// If an error occurs, log an error message and return an empty array
console.error('ERROR! 💥 ! Cannot read folder: ' + path);
console.error(
`ERROR! 💥 ! Cannot read folder: ${path}, err: ${err instanceof Error ? err.message : ''}`,
);
return [];
}

Expand Down Expand Up @@ -345,22 +349,22 @@ function getFileFullPath(fileName: string, cacheFolderPath: string): string {
}

/**
* This function takes a string parameter 'route' and replaces all '/' characters in it with '__' and returns the modified string.
* This function takes a string parameter 'cacheKey' and replaces all '/' characters in it with '__' and returns the modified string.
*
* @internal
* @param {string} cacheKey - The string representing the route to be converted into a file name.
* @param {string} cacheKey - The string representing the cacheKey to be converted into a file name.
* @returns {string} The modified string representing the file name obtained by replacing '/' characters with '__'.
*/
export function convertCacheKeyToFileName(cacheKey: string): string {
// replace all occurrences of '/' character in the 'route' string with '__' using regular expression
// replace all occurrences of '/' character in the 'cacheKey' string with '__' using regular expression
return cacheKey
.replace(new RegExp('/', 'g'), '__')
.replace(new RegExp('\\?', 'g'), '++');
}

/**
* This function takes a string parameter 'fileName' and replaces all '__' strings in it with '/' and returns the modified string.
* @param fileName - The string representing the file name to be converted into a route.
* @param fileName - The string representing the file name to be converted into a cacheKey.
*/
export function convertFileNameToCacheKey(fileName: string): string {
// replace all occurrences of '__' string in the 'fileName' string with '/' using regular expression
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.