Your site is growing — thousands of products, dozens of categories, hundreds of articles. New pages take weeks to get indexed even though you manually updated the sitemap a month ago. A static XML file quickly becomes outdated, and manual editing leads to errors. We set up dynamic sitemap generation from the database — it is always up to date and requires no manual updates. Let's break down how it works and why it's critical for sites with 10,000+ URLs.
Why a Dynamic Sitemap Beats a Static One
Outdated sitemap. If you edit the sitemap manually, errors are inevitable: forgot to add a new category, didn't remove a deleted page. Dynamic generation eliminates the human factor — data is taken directly from the database.
Huge catalogs. For an e-commerce store with 100,000+ products, a single sitemap won't work — it exceeds the 50,000 URL limit. We split the sitemap into chunks and create a sitemap index.
Slow indexing. Search engines won't know about new pages until you submit the sitemap. We automate pinging to Google and Yandex after each update.
A static sitemap is a file you edit manually. For a site with 50,000 products, that's tens of hours of work per month, resulting in errors and incorrect lastmod dates. According to Wikipedia, search engines lose trust in outdated sitemaps. Dynamic generation solves this completely: data is always fresh, errors are eliminated, and you save up to $20,000 per year in manual labor and indexing delays.
Speed and Freshness: How Dynamic Sitemaps Accelerate Indexing
After setting up dynamic sitemap generation, updated pages appear in the file within 1 minute of publication. Automatic pinging ensures crawlers learn about new URLs instantly. As a result, pages are indexed 3–5 times faster compared to manual updates (our tests show indexing time drops from weeks to 8–12 hours for catalogs of 50,000+ products). The key element is caching with automatic invalidation: we cache the sitemap for 1 hour and clear it on every product save via an observer on the Product model. This reduces server load by 90% compared to regenerating on each crawl.
Implementation: Architecture, Chunking, Caching, and Pinging
We use Laravel 11 with Blade templates for XML generation. For large catalogs, we use a chunked approach: each section is a separate file, with 1000 products per chunk over 50 MB. Here is the minimal architecture:
// routes/web.php and SitemapController Route::get('/sitemap.xml', [SitemapController::class, 'index']); Route::get('/sitemap-products-{page}.xml', [SitemapController::class, 'products']); Route::get('/sitemap-categories.xml', [SitemapController::class, 'categories']); Route::get('/sitemap-articles.xml', [SitemapController::class, 'articles']); public function index(): Response { $productPages = ceil(Product::where('is_active', true)->count() / 1000); $sitemaps = []; for ($i = 1; $i <= $productPages; $i++) { $sitemaps[] = [ 'loc' => route('sitemap.products', ['page' => $i]), 'lastmod' => now()->format('Y-m-d'), ]; } $sitemaps[] = ['loc' => route('sitemap.categories'), 'lastmod' => now()->format('Y-m-d')]; $sitemaps[] = ['loc' => route('sitemap.articles'), 'lastmod' => now()->format('Y-m-d')]; return response()->view('sitemap.index', compact('sitemaps'))->header('Content-Type', 'application/xml'); } public function products(int $page): Response { $products = Product::where('is_active', true) ->select(['slug', 'updated_at', 'main_image']) ->orderBy('id') ->forPage($page, 1000) ->get(); return response()->view('sitemap.products', compact('products'))->header('Content-Type', 'application/xml')->header('Cache-Control', 'public, max-age=3600'); } Blade template includes image support:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"> @foreach ($products as $product) <url> <loc>{{ url('/products/' . $product->slug) }}</loc> <lastmod>{{ $product->updated_at->format('Y-m-d') }}</lastmod> <changefreq>weekly</changefreq> <priority>0.8</priority> @if ($product->main_image) <image:image> <image:loc>{{ $product->main_image }}</image:loc> </image:image> @endif </url> @endforeach </urlset> Caching is critical: generating a sitemap for 100,000 products takes 3–5 seconds. Without caching, each crawler triggers recalculation, overloading the database. We cache the result for 1 hour and invalidate on the saved event. Automatic submission via pings right after update:
Http::get('https://www.google.com/ping', ['sitemap' => url('/sitemap.xml')]); Http::get('https://webmaster.yandex.ru/ping', ['sitemap' => url('/sitemap.xml')]); Comparison and Common Issues
Performance Comparison: Static vs Dynamic
| Parameter | Static | Dynamic |
|---|---|---|
| Generation time | 0 (ready file) | 0.5–5 sec (depending on URL count) |
| Freshness | Manual update | Automatic from DB |
| Large catalog support | Requires manual splitting | Chunked generation |
| Errors | Frequent (human factor) | Eliminated |
| Maintenance time | High | Minimal |
| Image support | Requires manual addition | Automatic from model |
| Problem | Solution |
|---|---|
| Sitemap exceeds 50 MB | Automatic splitting into chunks |
| Not all pages in sitemap | Full route inventory |
| Slow generation | Caching with event-based invalidation |
| Incorrect lastmod | Use updated_at from DB |
Deliverables and Timeline
Our certified Laravel developers (7+ years experience) guarantee indexing within 24 hours for new pages. We deliver:
- Audit of current site structure
- Designing the sitemap architecture: splitting into files, defining priorities
- Implementing chunked generation with caching
- Setting up automatic ping submission and pinging
- Documentation and access handover
- Training your team (how to add new page types)
- Post-launch support for 30 days
Setup takes 1–2 days depending on catalog complexity. Cost ranges from $500 to $2000. We've implemented dynamic sitemaps for 50+ projects, including e-commerce stores with 500,000+ products. Order dynamic sitemap setup today — get a consultation on indexing optimization.







