---
title: "How Often Should RAG Sources Be Refreshed? Change Checks"
description: "Check RAG sources hourly, weekly or monthly, by how fast they change. Sitemap lastmod, ETag, chunk hashes and removing deleted pages from the index."
url: https://proxynet.io/blog/rag-source-freshness-check
date: 2026-12-03
author: "Enver Kaya"
category: "AI"
lang: en
---

# How Often Should RAG Sources Be Refreshed? Change Checks

RAG source freshness means the chunks in your vector index still match the current version of the source page. A sync job checks the pages that may have changed on each run. It re-embeds the chunks that changed and deletes vanished pages from the index. The trap is on the delete side: if the chunks of a page that returns 404 stay in the index, the model cites information that no longer exists. This post covers source classes, sitemap and conditional request signals, chunk hashes and deletion rules.

> **Note: Short answer**
>
> Check fast-changing sources hourly or daily, docs weekly and archives monthly. On each run, re-embed only the chunks whose hash changed, and delete the chunks of pages that return 410 or two 404s in a row.

## Classes by rate of change

Check frequency follows how fast a source changes. One schedule does not fit the whole index. Put each source in a class and give the sync job that class's interval. The intervals below are starting values, not measurements.

| Class | Example source | Check interval | Main signal |
|---|---|---|---|
| Fast | Price list, status page, release notes | Hourly or daily | Conditional request, page hash |
| Medium | Product docs, help center, FAQ | Weekly | Sitemap lastmod |
| Slow | Guide archive, old blog posts | Monthly | lastmod, monthly full check |
| Static | Docs for old versions | Quarterly | Deletion check only |

Picking the right class on day one is hard. So record, for each page, how often its content changed over the last checks. Move a page that never changes down a class, and a page that changes on every check up a class.

A wrong class costs you both ways. Checking too often puts needless load on the source site. Checking too rarely leads the model to quote an old price or describe a removed feature. Decide where stale information costs the most and reserve the fast class for it.

## lastmod in the sitemap

The `<lastmod>` value in a sitemap gives the date a page last changed. It is the cheapest way to pick pages to check. One sitemap request returns the candidate list without visiting thousands of pages one by one. If you don't know where the sitemap is, follow the steps in [How to Find a Website's Sitemap](/blog/find-website-sitemap).

Under the sitemaps.org protocol, `<lastmod>` is optional and written in W3C date format. The value should reflect the page's own change, not the moment the sitemap was generated. Google says it uses the value only if it is consistently and verifiably accurate. `<changefreq>` is a hint, and Google ignores it. Don't build your schedule on it.

Don't trust lastmod on its own. Some sites reset every date to today on each build, others never update it. In the first case every run checks the whole site. In the second, changes slip through. So lastmod only picks candidates, and the conditional request and hash make the decision.

Two more details. A date-only value (`2026-12-01`) points to midnight. A change made the same day after your check is missed with that date, so the sample script treats such a value as the end of the day. A URL that is in the index but no longer in the sitemap also goes on the check list. Leaving the sitemap is not a deletion decision, only a reason to check.

## Conditional requests

A conditional request asks the server whether your copy is still current and skips the body download for an unchanged page. Store the `ETag` and `Last-Modified` values from the first response in the page record. Send them back on the next request in the `If-None-Match` and `If-Modified-Since` headers. If the page has not changed, the server returns `304 Not Modified` and the sync job skips that page. If the server does not send these headers, every check is a full download and the decision falls to the hash.

## Page and chunk hashes

A hash is a fingerprint of the text: change one character and the SHA-256 value changes too. The sync keeps hashes at two levels. The page hash tells you in one comparison whether anything on the page changed. The chunk hash shows what changed.

When a page changes, split the text into chunks again and hash each chunk. Then compare with the old list in the record. Only chunks that appear in the new list get embedded, and only chunks that appear in the old list get deleted. A chunk in both lists stays in the index as it is.

This works as long as chunk boundaries stay stable. In text split by a fixed token count, one sentence added at the top shifts every boundary after it. Then every chunk looks new and the whole page is re-embedded. Split chunks at heading and paragraph boundaries. The Markdown conversion and splitting step is covered in [Web Scraping for RAG: From HTML to Clean Markdown Chunks](/blog/web-scraping-for-rag).

Compute the hash from the extracted main text, not the raw HTML. Raw HTML carries session tokens, ad slots and dates that change on every request. Those values produce a new hash without any real change and waste embedding cost.

The exit country is another factor that moves the hash. Many sites change language, currency and stock information by the visitor's location. A page fetched from Germany on one run and from Türkiye on the next produces a different hash even when nothing changed. Fetch each source from the same country on every run and write the country into the source record. You can use [Residential Proxy](https://proxynet.io/residential-proxy) to fetch from a chosen country.

## Deleted and moved pages

Chunks of a page that no longer exists at the source are deleted from the index. If they stay, retrieval keeps finding them and the model presents invalid information with a source link. The status code makes most of the decision.

| Response | Meaning | Action in the index |
|---|---|---|
| 200, same hash | Unchanged | Leave it |
| 200, different hash | Changed | Embed new chunks, delete old ones |
| 304 | Unchanged | Record the check time only |
| 301 / 308 | Moved permanently | Delete chunks of the old URL, add the new URL |
| 410 | Likely gone for good | Delete all chunks |
| 404 | Missing, permanence unknown | Delete on the second 404 in a row |
| 5xx, timeout | Temporary error | Leave it, retry next run |

RFC 9110 states this distinction plainly. 410 says the resource has likely been removed permanently. 404 does not say whether the condition is temporary or permanent. Deleting a page that returns 404 briefly during a deploy and re-embedding it on the next run is wasted cost. The two-404 rule filters out that noise.

A 5xx response or a timeout is never a reason to delete. If the source server goes down for an hour while the sync runs, a rule that allows deletion empties that part of the index. Temporary redirects such as 302 are not a reason to delete either.

## The sync script

The script picks candidates from the sitemap, sends a conditional request to each one and returns two lists: chunks to embed and chunk IDs to delete. First, see which field lives where.

| Field | Where | What it does |
|---|---|---|
| `id` | Chunk | Hash of URL and text, used for comparison and deletion |
| `url` | Chunk | Source citation, bulk deletion when the page goes |
| `fetched_at` | Chunk | When the text was fetched, freshness filter |
| `etag`, `last_modified` | Page record | Conditional request |
| `page_hash`, `checked_at`, `misses` | Page record | Change decision and 404 counter |

`fetched_at` is useful in the model's answer too. You can add the date the source was fetched to the answer, or drop chunks older than a given date from retrieval. Write the embedding model's name into the chunk as well. When the model changes, every chunk is re-embedded regardless of its hash.

```python
import hashlib
import xml.etree.ElementTree as ET
from datetime import datetime, timezone

import requests

PROXY = "http://user:pass@pr.proxynet.io:8000"
NS = {"sm": "http://www.sitemaps.org/schemas/sitemap/0.9"}

def sha(text):
    return hashlib.sha256(text.encode("utf-8")).hexdigest()[:16]

def utc(value):
    t = datetime.fromisoformat(value)
    return t if t.tzinfo else t.replace(tzinfo=timezone.utc)

def split_chunks(text):
    # One chunk per paragraph, for the example
    return [p.strip() for p in text.split("\n\n") if p.strip()]

def urls_to_check(session, sitemap_url, index):
    root = ET.fromstring(session.get(sitemap_url, timeout=20).content)
    listed = set()
    check = []
    for node in root.findall("sm:url", NS):
        url = node.findtext("sm:loc", namespaces=NS).strip()
        lastmod = node.findtext("sm:lastmod", namespaces=NS)
        listed.add(url)
        if lastmod and len(lastmod) == 10:  # date only: treat as end of day
            lastmod += "T23:59:59+00:00"
        rec = index.get(url)
        if rec is None or lastmod is None or utc(lastmod) > utc(rec["checked_at"]):
            check.append(url)
    # Pages in the index that left the sitemap are checked too
    check += [u for u in index if u not in listed]
    return check

def sync_page(session, url, rec):
    headers = {}
    if rec.get("etag"):
        headers["If-None-Match"] = rec["etag"]
    if rec.get("last_modified"):
        headers["If-Modified-Since"] = rec["last_modified"]
    r = session.get(url, headers=headers, timeout=20, allow_redirects=False)
    now = datetime.now(timezone.utc).isoformat(timespec="seconds")
    rec["checked_at"] = now

    if r.status_code == 304:
        return [], []
    gone = r.status_code in (301, 308, 410)
    if r.status_code == 404:
        rec["misses"] = rec.get("misses", 0) + 1
        gone = rec["misses"] >= 2  # never delete on a single 404
    if gone:
        rec["gone"] = True
        return [], rec.get("chunks", [])
    if r.status_code != 200:
        return [], []  # 5xx, 302, first 404: old chunks stay

    rec["misses"] = 0
    rec["etag"] = r.headers.get("ETag")
    rec["last_modified"] = r.headers.get("Last-Modified")
    text = r.text  # in a real pipeline: convert the main text to Markdown
    page_hash = sha(text)
    if page_hash == rec.get("page_hash"):
        return [], []

    new = {sha(url + "\n" + c): c for c in split_chunks(text)}
    old = set(rec.get("chunks", []))
    rec.update(page_hash=page_hash, chunks=sorted(new), fetched_at=now)
    embed = [{"id": i, "text": c, "url": url, "fetched_at": now}
             for i, c in new.items() if i not in old]
    return embed, sorted(old - new.keys())

def sync(sitemap_url, index):
    session = requests.Session()
    session.proxies = {"http": PROXY, "https": PROXY}
    embed, delete = [], []
    for url in urls_to_check(session, sitemap_url, index):
        rec = index.setdefault(url, {})
        e, d = sync_page(session, url, rec)
        embed += e
        delete += d
        if rec.get("gone"):
            del index[url]
    return embed, delete
```

`sync()` returns two lists. Pass the `embed` list to the embedding model and the `delete` list to your vector database's delete call. Because the chunk ID is built from the URL and the text, IDs don't collide even when the same paragraph appears on two pages. The insert and delete logic on the vector side is covered in [What Is a Vector Database?](/blog/what-is-a-vector-database).

Write the `index` dictionary to a JSON file or a table at the end of each run. Order matters: write to the vector database first, then save the record. In the reverse order, a run cut off halfway leaves orphan chunks in the index.

## Troubleshooting

The symptom usually points to the signal itself:

- **Every run re-embeds every page.** The hash is computed from raw HTML or from a field that changes on each request. Compare the extracted text line by line between two runs.
- **Every run puts every page on the check list.** The site resets lastmod to today on each build. Leave this source to the conditional request and the hash.
- **Changes are never caught.** lastmod is not updated or holds a date only. Add a monthly full check for that source.
- **The index contains "page not found" text.** The site returns 200 for deleted pages. Add a check that recognizes that text and treat the page as deleted.
- **A 304 never arrives.** The server sends no ETag or a new ETag on every response. The script still works, it just does a full download on every check.
- **The model cites a removed page.** The delete list never reached the vector database. Compare the chunk IDs in the record with those in the database.

## How we tested

We ran the script on December 3, 2026, on Windows 11 with Python 3.13.17 and Requests 2.34.2. The target site and the proxy ran on the same local test server. The server returned 407 for requests without `user:pass`, sent an `ETag` for pages and returned 304 for a matching `If-None-Match`. In the example we wrote `pr.proxynet.io:8000` in place of the local address.

On the first run over four pages, 10 chunks went on the embed list. On the second run, three pages with an old lastmod were skipped, and the page without lastmod got a 304. On the third run, one paragraph changed on one page, and the others returned 410, 301 and 404 in turn. The result was one new chunk and six deletions. The page that returned 404 stayed in the index, and its two chunks were deleted after the second 404 on the fourth run. Chunks of a page returning 503 stayed in place.

## The bottom line

Classify sources by how fast they change, use the sitemap to pick candidates and the hash to decide. You can also fetch a fixed source list from the same country on every run with [Datacenter Proxy](https://proxynet.io/datacenter-proxy). Above all, set up the deletion rule: a dead page left in the index is a costlier mistake than a stale one.

## Sources

- [RFC 9110, §13 Conditional Requests: rfc-editor.org](https://www.rfc-editor.org/rfc/rfc9110.html#name-conditional-requests)
- [RFC 9110, §15.5.11 410 Gone and §15.5.5 404 Not Found: rfc-editor.org](https://www.rfc-editor.org/rfc/rfc9110.html#name-410-gone)
- [Sitemaps XML format, `<lastmod>` and `<changefreq>`: sitemaps.org](https://www.sitemaps.org/protocol.html)
- [Google Search Central, Build and submit a sitemap: developers.google.com](https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap)

## Frequently asked questions

### How often should RAG sources be updated?

It depends on how fast the source changes. A good start is to check fast-changing sources such as price and status pages hourly or daily, product docs weekly and archives monthly. Then record how many checks each page changed on. Move pages that never change to a slower schedule, and pages that change often to a faster one.

### Should I rebuild the index on every update?

No. Leave pages whose page hash did not change. For a changed page, compare the chunk hashes with the old list, embed only the new chunks and delete the ones that vanished. A full rebuild is needed only when you change the embedding model or the chunking rule. Then every chunk and vector changes together.

### Can I trust the sitemap lastmod value?

Partly. lastmod is good for choosing which pages to check, but it is not enough for the decision. Some sites update every date on each build, others never update them. Pick candidates with lastmod, then decide whether the page really changed with a conditional request and a content hash. Check pages without lastmod with a conditional request on every run.

### Should a page returning 404 be removed from the RAG index right away?

No, wait for the second 404 in a row. Under RFC 9110, a 404 does not say whether the condition is permanent. A page that returns 404 briefly during a deploy can come back on the next run. A 410, on the other hand, signals that the resource has likely been removed for good. When you see a 410, delete all of the page's chunks at once.

### What happens when the embedding model changes?

Every chunk is re-embedded. Vectors from different models do not share the same space and cannot be searched together. Write the model name into each chunk, build a separate index with the new model and switch retrieval to it once the migration is done. The content hashes stay the same meanwhile, only the vectors change.

### Why store fetched_at on every chunk?

To see freshness at the chunk level. `fetched_at` tells you the moment the text was taken from the source. You can add the source date to the answer, drop chunks older than a given date from retrieval, or spot which source has gone unchanged for a long time. Stored together with the source URL, these fields also drive deletion and source citation.
