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

fix: Improve caching mechanism for URL indexing status #75

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pmespresso
Copy link

@pmespresso pmespresso commented Sep 27, 2024

What did I change?

  • Modify shouldRecheck function to always process non-indexed URLs
  • Ensure "Submitted and Indexed" URLs are only rechecked after cache timeout
  • Optimize batch processing to avoid unnecessary API calls

Why did I change it?

Every run on the script was trying the process the same urls and then timing out.
Related: #51 #59

- Modify shouldRecheck function to always process non-indexed URLs
- Ensure "Submitted and Indexed" URLs are only rechecked after cache timeout
- Optimize batch processing to avoid unnecessary API calls
src/index.ts Outdated
@@ -120,11 +120,20 @@ export const index = async (input: string = process.argv[2], options: IndexOptio
];

const shouldRecheck = (status: Status, lastCheckedAt: string) => {
const shouldIndexIt = indexableStatuses.includes(status);
if (status !== Status.SubmittedAndIndexed) {
Copy link
Owner

Choose a reason for hiding this comment

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

this seems wrong, there are some statuses that should not force a recheck

or am I missing something?

Copy link
Author

Choose a reason for hiding this comment

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

Ah you're right, I overfit to my own personal issue.

My cache was saving "status": "Not found (404)", which is not currently part of the Status enum, so those were being skipped.

I should rather just add a new Status.NotFound to indexableStatus.

However, such things can be fixed quite quickly but because of the long cacheTimeout they'd be ignored for 2 weeks. Perhaps we can have a shorter timeout for NotFound or PageWithRedirect.

What do you think?

…ound)

- Maintain efficient long-term caching for stable, indexed URLs
- add NotFound to Status enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants