mirror of
https://github.com/BradNut/personal-website-sveltekit
synced 2025-09-08 23:20:18 +00:00
Console log.
This commit is contained in:
parent
17d8498e2a
commit
9ec7b8c188
2 changed files with 7 additions and 1 deletions
|
|
@ -44,12 +44,16 @@ export async function fetchArticlesApi(
|
|||
});
|
||||
|
||||
if (USE_REDIS_CACHE) {
|
||||
console.log('Using redis cache');
|
||||
const cached = await redis.get(entriesQueryParams.toString());
|
||||
|
||||
if (cached) {
|
||||
console.log("Cache hit!");
|
||||
const response = JSON.parse(cached);
|
||||
const ttl = await redis.ttl(entriesQueryParams.toString());
|
||||
|
||||
console.log(`Response ${JSON.stringify(response)}`);
|
||||
console.log(`Returning cached response with ttl of ${ttl} seconds`);
|
||||
return { ...response, cacheControl: `max-age=${ttl}` };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ export async function GET({ setHeaders, url }) {
|
|||
}
|
||||
|
||||
try {
|
||||
const response = await fetchArticlesApi('get', `fetchArticles`, {
|
||||
const response = await fetchArticlesApi('get', 'fetchArticles', {
|
||||
page,
|
||||
limit
|
||||
});
|
||||
|
||||
console.log(`JSON articles response: ${JSON.stringify(response)}`);
|
||||
|
||||
if (response?.articles) {
|
||||
if (response?.cacheControl) {
|
||||
if (!response.cacheControl.includes('no-cache')) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue