Skip to content

early-exit optimization using a HEAD request to check for existence f…#2

Open
stone-monkeys wants to merge 1 commit intomainfrom
adds-skip-if-exists-logic
Open

early-exit optimization using a HEAD request to check for existence f…#2
stone-monkeys wants to merge 1 commit intomainfrom
adds-skip-if-exists-logic

Conversation

@stone-monkeys
Copy link
Copy Markdown
Collaborator

@stone-monkeys stone-monkeys commented Oct 3, 2025

Missing Early-Exit Optimization

CircleCI’s native save_cache checks if the key already exists before recompressing. The S3 orb always creates the archive even if it already exists in the bucket. That’s wasted time.

Would be great to implement:

HEAD request to check existence before compressing

If exists > skip compression/upload

HEAD Request Check:

  • Before compressing anything, the script now performs a aws s3api head-object call to check if the cache already exists in S3

Early Exit: If the object exists, it prints a message and exits with success (0), skipping:

  • The expensive tar compression step
  • S3 configuration
  • The upload operation

Proceed if Missing:

  • Only if the cache doesn't exist will it proceed with compression and upload

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.

1 participant