Check 38.13 · Freshness and accuracy

Update lastmod

Make your sitemaps' lastmod move when a price, opening hours or data really change, on WordPress, WooCommerce, Laravel, Next.js or Cloudflare.

Priority
Important
Difficulty
Intermediate
Estimated time
2 to 4 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

A sitemap with a reliable <lastmod> is not enough: the date also has to change at the moment a piece of changing data actually changes, on the pages where it matters, and the published file must not be a cached copy. The work consists of linking each tracked piece of data (price, availability, opening hours, version, executive) to the pages that show it as main content, then checking that their date follows, no more and no less. Expected result: a price cut published at 10 a.m. appears in the sitemap at 10 a.m., and a simple sale does not move any date.

Why it matters

The check provide a reliable lastmod (opens in a new tab) deals with generating the sitemap. This one deals with what happens next, day to day, when data changes. Three gaps are common:

  • The data lives somewhere other than the page. The price is in a variants table, the opening hours in a settings page, the version number in a configuration file. The displayed content changes, but the page's modification date does not move.
  • The date moves too much. On WooCommerce, every save of a product updates its modification date: according to WooCommerce's code, this also happens when an order reduces the stock. The sitemap then announces a change with every sale.
  • The published file lags behind. A cache plugin, a CDN (content delivery network) or a sitemap generated at build time serves a version that is several days old.

Both search engines read this date. Google uses <lastmod> when it is consistently and verifiably accurate, and retired its sitemap ping endpoint in 2023: the sitemap date is the signal that remains. Bing generally rereads submitted sitemaps at least once a day and links this freshness to how quickly content is reflected in its AI-generated answers. A page whose price has dropped but whose date stays frozen will be recrawled at random; a sitemap that announces a hundred changes a day without any real change loses the search engine's trust.

What it improves

  • Recrawling of the pages that matter Product pages whose price, availability or opening hours have changed are flagged the same day.
  • Accuracy of AI answers Corrected data is more likely to be picked up quickly by engines that rely on Bing's or Google's index. No timeframe or citation is guaranteed.
  • Credibility of the signal Dates only move for significant changes, which keeps the tag useful in the search engines' eyes.
  • Rankings No direct effect. A recent date does not make a page more relevant.

How to check

Real-world scenario test. Change a tracked piece of data on a page (a product's price, for example), wait a few minutes, then read that URL's entry in the sitemap that contains it:

curl -s https://example.com/wp-sitemap-posts-product-1.xml | tr -d '\n' \
  | grep -o '<loc>[^<]*the-vert-sencha[^<]*</loc>[[:space:]]*<lastmod>[^<]*'

Compliant result: the date and time of your change. Then do the opposite: a test order, a footer change. The date must not move.

Cache. Read the sitemap's headers:

curl -sI https://example.com/sitemap.xml | grep -i -E "cf-cache-status|age|cache-control|x-cache"

An age of several hours or a cf-cache-status: HIT on a sitemap that should reflect your latest changes indicates a cached copy.

Volume. Count the URLs dated today and compare with the number of real changes made during the day:

curl -s https://example.com/wp-sitemap-posts-product-1.xml | grep -o "<lastmod>$(date +%Y-%m-%d)" | wc -l

Two hundred product pages dated today for three prices changed: the date is following something other than the content.

How to implement

Before you start

Start from the inventory of the check list the data that changes over time (opens in a new tab) and add two columns: the pages where each piece of data is main content, and the rule for updating the date.

Data Pages where it is main content Update lastmod?
Product price Product page Yes, on every published change
Availability Product page Yes when it goes out of stock or comes back in stock; not on every sale
Opening hours Contact page, location page Yes; not the other pages that repeat them in the footer
Software version Release notes, download page, installation documentation Yes
Executive, team Team page, about page Yes
Regulatory notice Page concerned, terms and conditions Yes

Common rules:

WordPress

Versions WordPress 6.5 and later, WooCommerce 9 and later, ACF 6.

The native sitemap, Yoast SEO and Rank Math date posts with their modification date (post_modified_gmt). To make it reliable, manage a separate editorial date, the _date_maj_editoriale meta in UTC, connected to the sitemap through the wp_sitemaps_posts_entry filter described in provide a reliable lastmod (opens in a new tab). Then add the following triggers in a custom plugin or in a child theme's functions.php.

WooCommerce price and availability. The woocommerce_product_object_updated_props action tells you which properties actually changed:

add_action('woocommerce_product_object_updated_props', function (WC_Product $product, array $updatedProps): void {
    $significantProps = ['regular_price', 'sale_price', 'stock_status'];

    if (! array_intersect($significantProps, $updatedProps)) {
        return;
    }

    $productId = $product->get_parent_id() ?: $product->get_id();

    update_post_meta($productId, '_date_maj_editoriale', gmdate('Y-m-d H:i:s'));
}, 10, 2);

A variation updates the date of its parent product, the only one present in the sitemap. The stock quantity (stock_quantity) is deliberately left out: only going out of stock or coming back in stock counts.

Opening hours in an ACF options page. When a global value changes, date only the pages where it is main content:

add_filter('acf/update_value/name=horaires', function ($value, $postId, array $field) {
    if ($postId !== 'options') {
        return $value;
    }

    if (get_field('horaires', 'option', false) == $value) {
        return $value;
    }

    $contactPage = get_page_by_path('contact');

    if ($contactPage) {
        update_post_meta($contactPage->ID, '_date_maj_editoriale', gmdate('Y-m-d H:i:s'));
    }

    return $value;
}, 10, 3);

Initialization. Give existing content a starting date, once only, with WP-CLI:

for id in $(wp post list --post_type=product --post_status=publish --format=ids); do
  wp post meta update "$id" _date_maj_editoriale "$(wp post get "$id" --field=post_modified_gmt)"
done

Cache. If a cache plugin or the host's cache serves the sitemaps, exclude the /wp-sitemap paths (or /sitemap_index.xml and -sitemap.xml with Yoast and Rank Math) from page caching, then check with curl.

Shopify

Versions Shopify, all plans, November 2026.

Shopify generates /sitemap.xml and its child files on its own, dates included: you can neither choose the date nor exclude a change. After a price cut, check that the product page appears with the new date in the products file listed in /sitemap.xml. Above all, avoid apps that rewrite descriptions or metadata in bulk for no reason: they date the entire catalog on the same day.

Laravel

Versions Laravel 11 to 13, spatie/laravel-sitemap 7.

With the content_updated_at column from provide a reliable lastmod (opens in a new tab), carry over to the product the changes made in related models. Create an observer for variants:

namespace App\Observers;

use App\Models\Variant;

class VariantObserver
{
    public function updated(Variant $variant): void
    {
        if (! $variant->wasChanged(['price', 'is_available'])) {
            return;
        }

        $variant->product->forceFill(['content_updated_at' => now()])->saveQuietly();
    }
}

Register it on the model with the #[ObservedBy(VariantObserver::class)] attribute (class Illuminate\Database\Eloquent\Attributes\ObservedBy). saveQuietly() avoids triggering the product's other observers.

Caution: mass updates through the query builder (Variant::where(...)->update([...])), common in price imports, do not fire any Eloquent event. In that case, date the products concerned in the same operation: Product::whereIn('id', $productIds)->update(['content_updated_at' => now()]);.

If the sitemap is written to a file by a command, schedule it often enough in routes/console.php, otherwise the file keeps the old dates:

use Illuminate\Support\Facades\Schedule;

Schedule::command('sitemap:generate')->hourly();

sitemap:generate refers here to your own generation command. If the sitemap is served dynamically with Cache::remember(), call Cache::forget() on its key in the observer.

Next.js

Versions Next.js 15 and 16 (App Router).

app/sitemap.ts is a route handler cached by default: without revalidation, it keeps the build dates. Two solutions, to choose according to your update pace.

Periodic revalidation, at the top of app/sitemap.ts:

export const revalidate = 3600

On-demand revalidation, in the handler called by the CMS webhook after a change:

// app/api/publication/route.ts
import { revalidatePath } from 'next/cache'
import { NextResponse } from 'next/server'

export async function POST(request: Request) {
  if (request.headers.get('x-webhook-secret') !== process.env.WEBHOOK_SECRET) {
    return NextResponse.json({ error: 'forbidden' }, { status: 403 })
  }

  const { path } = await request.json()
  revalidatePath(path)
  revalidatePath('/sitemap.xml')

  return NextResponse.json({ revalidated: true })
}

In both cases, lastModified must come from an editorial field in the CMS, updated when the price or data changes, never from new Date(). If you have enabled Cache Components (Next.js 16), the revalidate setting no longer applies in the same way: follow the caching documentation for your version.

Cloudflare

Versions Cloudflare dashboard, all plans, November 2026.

By default, Cloudflare caches neither HTML nor XML files: a sitemap is only frozen if a “cache everything” rule covers it. In that case, exclude the sitemaps in Cache Rules: Create rule, custom filter expression:

(starts_with(http.request.uri.path, "/sitemap") or starts_with(http.request.uri.path, "/wp-sitemap"))

Cache eligibility: Bypass cache. Place the rule after the general rule: when two cache rules conflict, the last one that matches wins. After deployment, purge the sitemap once in Caching > Configuration, Custom Purge, then check for cf-cache-status: DYNAMIC or BYPASS with curl.

Shared hosting

With a sitemap written by hand or exported by a tool, updating the date is a step in the change procedure: change the data, change the page's <lastmod> in the same FTP upload, with the date and time in the format 2026-11-25T10:00:00+01:00. Add this line to the procedure sheet of the owner designated in assign an owner to each piece of content (opens in a new tab).

Common mistakes

  • Dating every page when a global piece of data changes: a new phone number in the footer only changes the main content of the contact page.
  • Letting sales date the product pages: the stock quantity changes with every order, availability does not.
  • Forgetting imports and syncs: an ERP (enterprise resource planning system) that updates prices through direct database queries triggers no hook or observer.
  • Correcting the page without regenerating the sitemap: a static file, a plugin cache or a Next.js build freezes the old date.
  • Dating when a scheduled sale was entered instead of when it goes live.
  • Refreshing dates without any change to look up to date: this is a practice to avoid (opens in a new tab).

Frequently asked questions

Should lastmod change when only a product's price changes?

Yes, a price change is a significant change to the main content of a product page, just like availability or specifications. The product page's lastmod date must follow the day the new price is published. On the other hand, a change in stock quantity after a sale changes nothing useful for the search engine and must not modify the date.

Why does my WooCommerce sitemap change date with every order?

WooCommerce updates a product's modification date on every save, including when an order reduces the stock. The native sitemap, Yoast SEO and Rank Math reuse this date, which then follows sales rather than content. The solution is to manage a separate editorial date, updated only when the price or stock status changes, and to connect it to the sitemap.

Should lastmod be updated on every page when opening hours change?

No, only on the pages where the opening hours are main content: the contact page and the location page. The other pages that repeat them in the footer or sidebar do not change significantly in Google's sense. Dating the whole site for a global piece of data drowns the signal and can lead search engines to ignore the lastmod tag.

Should I resubmit the sitemap to Google after every update?

No, there is no need to resubmit a sitemap already declared in Search Console or in the robots.txt file after every change. Google rereads it on its own and retired its ping endpoint in 2023; Bing generally rereads submitted sitemaps at least once a day. For Bing and compatible search engines, an IndexNow notification speeds up the processing of a specific URL.

Updated on

Topic checklist (PDF)

And now?

In the “Freshness and accuracy” topic

  1. List the data that changes over time
  2. Define a review frequency
  3. Assign an owner to each piece of content
  4. Update prices, stock and opening hours
  5. Update contact details
  6. Update technical specifications
  7. Update regulatory information
  8. Update statistics and comparisons
  9. Update software versions
  10. Update leadership and team information
  11. Display the actual modification date
  12. Update dateModified
  13. Update lastmod
  14. Notify compatible search engines via IndexNow
  15. Remove incorrect information
  16. Test whether AI systems cite outdated data
  17. Identify outdated sources
  18. Correct accessible official and third-party sources