Object storage lifecycle rules for raw page captures

The bucket that only ever grows

Every collector that keeps raw pages has the same storage graph: a line going up and to the right at a steady angle, forever. Nobody decided to keep everything. The collector writes each capture to a bucket, the bucket accepts it, and nothing ever takes anything away. A year in, the raw capture bucket can be one of the larger lines on the infrastructure bill, and most of what’s in it hasn’t been read since the week it was written.

The decisions about what to keep and for how long are covered elsewhere in this series. The retention guide works through how long raw HTML is worth keeping after a project ends. The storage-format guide covers WARC files, bundling and compression choices. Both end with some version of “put it in object storage with a lifecycle rule.” This article is about that rule: how lifecycle configuration actually works on S3-style storage, how to lay out keys so rules can target the right objects, which storage classes to move captures through, and the traps that make a sensible-looking rule cost more than no rule at all.

Most of the specifics below use Amazon S3’s documented behaviour, because it’s the reference implementation that many other providers copy. Other providers differ in which actions and storage classes they support, and there’s a section on that near the end. Check your provider’s documentation for current prices and limits, which change, and which we deliberately don’t quote here.

We keep raw captures for our own collection jobs in object storage under rules like these, and the design is shaped by one principle. Captures are read heavily in their first weeks, when parser fixes, dead-letter replays and debugging happen, and almost never after that. The rules should follow that curve. Recent captures stay in a storage class that’s cheap to read. Older ones move to classes that are cheap to hold. And everything expires when the retention policy says it should, automatically, without anyone remembering to run a cleanup.

What a lifecycle rule actually is

A lifecycle configuration is a set of rules attached to a bucket. Each rule has a filter that selects objects and one or more actions that apply to them once they reach a certain age.

Filters select by key prefix, by object tags, by object size, or by a combination. A rule might apply to every object under raw/, or to objects tagged class=capture, or to objects larger than a given size under a given prefix. Filters can’t select on arbitrary metadata, content type, or anything inside the object, which is why key layout and tagging matter so much.

Actions come in a few kinds. Transition actions move objects to a different storage class after a number of days. Expiration actions delete objects after a number of days. Separate actions handle noncurrent versions in versioned buckets, removing expired delete markers, and aborting multipart uploads that never finished.

Age is counted from the object’s creation time, which for captures is effectively the fetch time, as long as you write captures promptly after fetching. If you batch uploads, or re-upload objects during a migration, the age resets to the new write, which can keep objects hot longer than intended.

Lifecycle processing is asynchronous. The storage service evaluates rules periodically, and actions happen some time after an object becomes eligible, not at the exact moment. For expiration, billing for the object stops once it’s eligible even if the deletion itself lands later. For transitions, expect a delay. Don’t build anything that depends on an object being in a particular class on a particular day.

Rules apply to existing objects as well as new ones. Adding an expiration rule to a bucket full of old captures will, once processed, delete every object already past the threshold. That’s usually the point. It’s also why a new rule should be tested on a narrow prefix before it’s applied to the whole bucket.

Laying out keys so rules can find them

Because filters work on prefixes and tags, the key layout of a capture bucket is effectively its lifecycle policy’s vocabulary. A layout chosen for convenience at write time can make the right rules impossible to express later.

The layout that works best puts the dimensions you’ll want different rules for at the front of the key. For raw captures, that’s usually the kind of object first, then the retention class, then the source, then the date. Something like raw/<retention-class>/<source>/<yyyy>/<mm>/<dd>/<capture-id>.html.zst.

The kind prefix separates raw captures from other things in the bucket, such as bundles and indexes, or screenshots and exports, which need different rules. The retention class prefix is the important one. It groups captures by how long they must be kept, such as standard, short for low-value sources, and extended for sources under a client agreement that requires longer retention. Each retention class gets its own rules, and moving a source between classes is a change to where the collector writes, not a change to the rules.

The lifecycle rules themselves ignore the source and date components, since age comes from the object’s creation time. Those components serve everything else: finding a day’s captures for a source during debugging, bundling captures by day, and deleting one source’s captures by prefix when a client relationship ends.

Tags are the alternative to prefix-based classes. You can tag each capture on upload with its retention class and filter rules by tag. Tags are more flexible, because they can be changed without moving objects, but they cost a little per object, they’re limited in number per object, and they’re easier to forget or misapply than a prefix that’s baked into the key. For raw captures, where the class is known at write time and rarely changes, prefixes are simpler.

Avoid putting the URL in the key. URLs contain characters that make awkward keys and can be very long. A hash of the canonical URL plus the fetch time, or a capture ID, is cleaner, with the URL recorded in metadata or in an index.

Compress before anything lands

Lifecycle rules decide where objects live. They do nothing about how big the objects are, and every storage class bills by size, so compression is the first lifecycle decision even though it isn’t a lifecycle rule.

HTML compresses very well. It’s verbose, repetitive text, and pages from one site share huge amounts of boilerplate. Compressing each capture before upload, with gzip for maximum compatibility or zstd for better ratios and faster decompression, cuts the stored size of every object in every class for the rest of its life. The storage-format guide in this series covers the choice between algorithms in more detail.

Compress in the collector, before upload, and store the compressed bytes as the object. Record the encoding in the key suffix and in the object’s Content-Encoding or metadata, so readers know what to do with it. Don’t rely on the storage service to compress for you. Standard S3-style object storage stores exactly the bytes you send.

Zstd with a trained dictionary is worth knowing about for per-page captures from a single site. A dictionary built from a sample of that site’s pages captures the shared boilerplate, so each individual page compresses much better than it would on its own. The cost is that you have to keep the dictionary alongside the captures, versioned, forever, because a capture compressed with a dictionary can’t be read without it. For many teams, bundling, covered next, gets most of the same benefit with less to manage.

One more consideration: compressed objects are smaller, which matters for the next section. Several storage classes have a minimum billable object size, and compression pushes more of your captures below it.

The small-object problem

This is the trap that catches most capture buckets, and it’s why a lifecycle rule copied from a tutorial can cost more than it saves.

A single compressed product page is small. Often tens of kilobytes. Storage classes designed for infrequent access and archiving are priced on the assumption of larger objects, and their pricing reflects that in two ways.

Minimum billable size. On S3, the infrequent-access classes and Glacier Instant Retrieval bill each object as if it were at least 128 KB. A 20 KB capture moved into one of those classes is billed as 128 KB. Moving millions of small captures there can raise the storage bill rather than lower it. S3 lifecycle rules now skip transitions for objects smaller than 128 KB by default for exactly this reason, which means a rule you expected to move everything may quietly move almost nothing.

Per-object overhead in archive classes. Objects moved to Glacier Flexible Retrieval and Glacier Deep Archive carry a fixed amount of extra metadata storage per object, part of it billed at the archive rate and part at the standard rate. For large objects it’s negligible. For a small capture it can be a significant fraction of the object’s own size.

Per-object transition requests. Each transition is a request, and requests are billed per object. Transitioning millions of small objects costs a request fee for each, which for small objects can take a long time to earn back through the lower storage rate.

The combined effect: tiering millions of individual small captures is often uneconomic. The fix is fewer, larger objects, and no rule can give you those.

Intelligent-Tiering, which moves objects between tiers automatically based on access, has the same issue from a different angle: objects smaller than 128 KB aren’t eligible for automatic tiering and stay in the frequent-access tier. It doesn’t rescue small captures either.

Bundling captures before they go cold

The practical answer to the small-object problem is to keep individual captures only while they’re hot, then pack them into larger bundles before tiering.

The pattern runs as a daily job. Captures land as individual compressed objects under raw/<class>/<source>/<date>/, where they’re easy to read one at a time during the first days, when debugging and replays happen. After a set number of days, a bundling job reads each source’s captures for a day and writes them into one or a few large archives, then writes an index recording where each capture lives inside its bundle. Once the bundle and index are verified, the individual objects are deleted, either by the job or by an expiration rule on the individual-capture prefix that fires shortly after the bundling window.

The bundles live under a separate prefix, such as bundles/<class>/<source>/<yyyy>/<mm>/, with their own lifecycle rules. Because each bundle holds many captures, it’s comfortably above minimum billable sizes, transitions cost one request per bundle instead of one per page, and archive-class overhead becomes negligible.

WARC is the natural bundle format for raw HTTP captures, since it keeps headers alongside bodies and has existing readers. It’s the format the storage-format guide recommends for archival use. A tar of compressed files or a columnar file with one row per capture also works, as long as the index lets you find a single capture without reading the whole bundle. With WARC, the index records byte offsets for each record, and a ranged read against object storage fetches just that record.

The index is small and read often, so keep it in a hot class or in a database. It maps capture ID, URL and fetch time to bundle key and offset. Anything that references a capture, such as a dead letter entry or a record’s provenance, should be able to resolve through it.

Bundling adds a job to run and monitor. For buckets holding more than a few million captures, it’s usually the single biggest cost lever after compression.

Storage classes and their minimum durations

Once captures are bundled, the storage class ladder becomes useful. On S3, the classes relevant to raw captures, from hottest to coldest, start at Standard and step down through Standard-Infrequent Access and Glacier Instant Retrieval to Glacier Flexible Retrieval, with Glacier Deep Archive at the bottom. There’s also a single-zone infrequent-access class that trades resilience for price, which some teams accept for data they could regenerate.

Each step down is cheaper to hold and more expensive or slower to read. Standard has no retrieval fee. The infrequent-access classes and Glacier Instant Retrieval charge per gigabyte retrieved but return data immediately. Glacier Flexible Retrieval and Deep Archive require a restore request before an object can be read, which takes minutes to hours depending on the class and retrieval option, and the restored copy is temporary.

Every class below Standard has a minimum storage duration. Delete or transition an object out before that duration and you’re charged for the remainder. On S3 that’s 30 days for the infrequent-access classes, 90 days for Glacier Instant Retrieval and Glacier Flexible Retrieval, and 180 days for Deep Archive. Lifecycle rules also require objects to have been in Standard for at least 30 days before transitioning to the infrequent-access classes.

Minimum durations shape the whole ladder. There’s no point moving a bundle to Deep Archive if your retention policy deletes it two months later, because you’ll pay for six months anyway. A rule that transitions to Glacier Instant Retrieval at 60 days and expires at 120 pays the 90-day minimum and saves little.

So work backwards from the expiration date. If captures expire at a year, a ladder of Standard for the first month, infrequent access until around three months, and an archive class after that respects every minimum. If they expire at 90 days, a single transition to infrequent access at 30 days may be all that’s worth doing. If they expire at 30 days, don’t tier at all, just expire.

Matching tiers to how captures are reread

The ladder should follow how your team actually reads captures, which has a characteristic shape in collection pipelines.

In the first days after a fetch, captures are read constantly. Parsers may run asynchronously from storage. Failed parses land in the dead-letter queue and get replayed after fixes. Engineers open captures to debug extraction problems. This is when captures must be in Standard, readable instantly and without retrieval fees, and when individual objects are most convenient.

For the next few weeks, reads drop off but don’t stop. A parser fix might trigger a reparse of the last month, as the reparsing guide describes. An analyst might question a value from two weeks ago and someone opens the capture to check. Reads are occasional and usually in batches by source and date range. Infrequent-access classes fit well: storage is cheaper, retrieval is immediate, and the retrieval fee on an occasional batch is small next to the storage saving.

After a few months, reads become rare and planned: a backfill of a new field across the last quarter, a compliance request, a historical investigation. Latency of hours is acceptable because the work is scheduled. That’s the territory of the archive classes, with bundles and a hot index so a restore can be targeted at exactly the bundles needed.

Look at your own access patterns before committing. Storage access logs or analytics tools like S3 Storage Lens show how often objects of each age are read. If your team reparses the full last quarter every time a parser changes, captures from the last quarter aren’t cold, and moving them to an archive class will make every reparse slow and expensive.

The reparse horizon is the number that matters most. Keep everything inside it immediately readable.

Expiration that enforces the retention policy

Expiration is the rule that actually stops the line going up. It deletes objects a fixed number of days after creation, and it’s where the retention decision becomes automatic.

The retention guide in this series covers deciding the number: how long raw captures stay useful after collection, and after a project ends. The lifecycle rule enforces it. Each retention class prefix gets an expiration rule with its number of days, on both individual captures and bundles. A source moved to a shorter class starts expiring on the new schedule for captures written after the move. Captures already written stay under their old prefix and old rule, which is usually what you want, since they were collected under the old terms.

Expiration by age can’t handle project-end deletion, where every capture for a source must go when a client relationship ends regardless of age. That’s a deliberate prefix deletion, run as a job, and the source-first key layout makes it one operation per retention class. Record it in the same place you record retention decisions.

It also can’t handle deletion requests for specific content, such as removing captures that turned out to contain personal data. Those need targeted deletes, found through the capture index, and they’re harder inside bundles: removing one capture from a WARC means rewriting the bundle without it. If you expect such requests, keep bundles small enough that rewriting one is cheap, and keep the index accurate enough to find every copy.

Be careful with expiration and anything that still references a capture. A dead letter entry pointing at a raw page that’s been expired can no longer be replayed. The pinning section below covers keeping referenced captures alive.

Finally, make the expiration visible. A monthly note of how many captures expired per class and how much storage that freed tells everyone the policy is working.

Versioning and the versions you forgot

Bucket versioning is a common source of lifecycle surprises, because it changes what “delete” means.

In a versioned bucket, deleting an object doesn’t remove it. It adds a delete marker, which hides the object from normal listing, and the previous version becomes a noncurrent version that’s still stored and still billed. An expiration rule on current versions does exactly this: it adds delete markers. Without a rule for noncurrent versions, every expired capture keeps costing money, and the bucket’s storage graph doesn’t bend at all even though the rule is working as designed.

The fix is a noncurrent-version expiration rule alongside the current-version one, which permanently deletes noncurrent versions a number of days after they become noncurrent. Add a rule to remove expired delete markers too, so markers for objects with no remaining versions don’t pile up and slow down listings.

Ask whether a capture bucket needs versioning at all. Versioning protects against accidental overwrites and deletions, which matters for data you can’t regenerate. Raw captures are write-once by nature: each capture has a unique key and is never updated. Overwrites shouldn’t happen, and if a bug causes them, the bug is the problem. Many teams leave capture buckets unversioned and rely on object lock, replication or backups for the protection they actually need.

If versioning is required, for example because the bucket is replicated to another region, which requires versioning on S3, then noncurrent-version rules are mandatory, as part of the retention policy. Set the noncurrent retention short, since noncurrent versions of write-once captures exist only because something deleted or overwrote them.

Check an existing versioned bucket for noncurrent bytes before assuming its rules work. A storage inventory report broken down by current and noncurrent versions often explains a bill that never went down.

The costs rules forget

A few costs sit outside the obvious storage-per-gigabyte line, and lifecycle configuration is where most of them get handled.

Incomplete multipart uploads. Large objects, such as bundles, are usually uploaded in parts. If an upload fails partway and is never completed or aborted, the uploaded parts stay in the bucket, invisible to normal listing and billed as storage. A lifecycle rule that aborts incomplete multipart uploads after a few days cleans these up. It costs nothing to add and belongs in every capture bucket’s configuration.

Transition request fees, covered above, which make tiering individual small captures expensive. Bundle first.

Early deletion charges from minimum durations. These come from rules where the expiration date falls before the minimum duration of the class an object was moved to, and from ad hoc deletions of objects in cold classes. Design the ladder around the expiration date and they don’t happen.

Retrieval and restore fees. An unplanned full-quarter reparse from an archive class can cost more than the storage saving that put the captures there. If reparses of that range are routine, the range belongs in a hotter class.

Listing and request costs. Jobs that list the whole bucket to find captures, rather than using the index or date prefixes, generate large numbers of list requests. The key layout and the index keep these down.

Monitoring costs. Intelligent-Tiering charges a small monthly fee per monitored object, which adds up across millions of objects and doesn’t apply to objects under 128 KB, which aren’t auto-tiered anyway. For predictable capture access patterns, explicit rules are usually cheaper than paying to have the pattern discovered.

Pinned captures and holds

Some captures must outlive their normal expiration, and lifecycle rules have no built-in way to exempt individual objects from a prefix rule. Filters can include by prefix and tag but can’t exclude.

The usual reasons to keep a capture longer are an open dead-letter entry that hasn’t been replayed, a dispute or investigation where the capture is evidence of what a page showed, a regression test built from a real failure, or a client agreement that requires specific captures to be kept.

The clean solution is a separate prefix for pinned captures with its own rules. When something needs a capture kept, copy it to pinned/<reason>/... and record the pin in the index with an owner and a review date. The original expires on schedule. The pinned copy lives under rules that match its reason, such as a long expiration for evidence or none at all for regression fixtures, and it’s removed deliberately when the pin is released.

For captures inside bundles, pinning means extracting the capture from the bundle into the pinned prefix. That’s another reason to keep a reliable index.

For legal or compliance holds, S3 Object Lock provides retention periods and legal holds that prevent deletion, including by lifecycle rules, until the hold is released. It requires versioning on the bucket, it’s strict by design, and a compliance-mode retention can’t be shortened even by the account owner. Use it only where the requirement is real and understood, and keep locked captures under their own prefix.

Review pins periodically. A pinned prefix without review dates slowly becomes a second archive with no retention policy.

Other providers and what they support

Lifecycle management exists on most object stores, but the actions and classes differ, and a design built on one provider doesn’t always translate.

Google Cloud Storage supports lifecycle rules with actions to change storage class and to delete, and conditions on age and creation date, as well as storage class and version state. Its Nearline, Coldline and Archive classes have their own minimum storage durations and retrieval fees, with Archive’s minimum longer than S3 Deep Archive’s.

Azure Blob Storage has lifecycle management policies that move blobs between hot, cool, cold and archive tiers and delete them, filtered by prefix and blob index tags. The archive tier requires rehydration before reading, similar to S3’s archive classes.

Some S3-compatible providers support only part of the S3 lifecycle vocabulary. Several support expiration but offer limited transitions or none, because they have a single storage class, sometimes with an infrequent-access option. Self-hosted systems like MinIO implement lifecycle management including expiration and tiering to other storage targets. On any of these, check which actions are supported before designing a ladder, and assume nothing about small-object behaviour or minimum durations until you’ve read the provider’s documentation.

The parts of this design that transfer everywhere are the ones that don’t depend on the provider: compress before upload, lay out keys by kind and retention class, then source and date, bundle small captures before they go cold, keep a hot index, expire on a schedule tied to the retention policy, abort incomplete uploads, and pin deliberately.

Verifying the rules and what to do on Monday

Lifecycle rules fail silently. A filter with a typo matches nothing and throws no error. A rule on a versioned bucket without a noncurrent rule appears to work. So verify with data, not by reading the configuration.

Use your provider’s inventory reports, which list each object with its storage class and size, plus its age and version state, on a schedule. From them, chart bytes per prefix per storage class per age band, and noncurrent bytes separately. Captures older than your expiration date shouldn’t exist. Captures older than a transition threshold shouldn’t be in Standard. If either shows up, the rule isn’t doing what you think.

Test new rules on a narrow canary prefix first, wait for a processing cycle, and check the inventory before widening the filter.

On Monday, pull an inventory of your capture bucket and look at object sizes and ages, then storage classes and noncurrent bytes. Add an abort-incomplete-multipart rule. If versioning is on, add noncurrent-version and delete-marker rules, or decide whether versioning is needed. Set an expiration rule that matches your retention policy. If most captures are small and you keep them longer than a month or two, plan a bundling job and an index before adding transitions. Then design the transition ladder backwards from the expiration date, respecting minimum durations and your reparse horizon, and check the inventory again next month.

For more on raw storage, retention and the reparsing that depends on them, the full set of guides is at Data Research Tools.

Get new guides and videos first — join the Telegram channel.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *