perf: reduce web requests with caching, bot control, and deferred JS

Add robots.txt to block aggressive AI scrapers (GPTBot, Bytespider,
SemrushBot, etc.) and set crawl delays for legitimate search engines.

Add Cache-Control headers for HTML pages (1h TTL with
stale-while-revalidate) so repeat visits are served from Netlify's
CDN edge cache instead of origin.

Defer below-fold video components from client:load to client:visible
so their JS chunks only load when scrolled into view — bots and users
who don't scroll never trigger those requests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mudskipper
2026-03-03 11:44:54 +11:00
parent a91cfcb7d1
commit bb9dcd1797
3 changed files with 93 additions and 2 deletions

25
public/_headers Normal file
View File

@@ -0,0 +1,25 @@
# HTML pages — 1 hour cache, serve stale while revalidating
/*
Cache-Control: public, max-age=3600, stale-while-revalidate=86400
# Hashed build assets — immutable forever
/_astro/*
Cache-Control: public, max-age=31536000, immutable
/fonts/*
Cache-Control: public, max-age=31536000, immutable
/favicon.ico
Cache-Control: public, max-age=604800
/favicon.svg
Cache-Control: public, max-age=604800
/*.svg
Cache-Control: public, max-age=86400
/*.pdf
Cache-Control: public, max-age=604800
/sitemap-*.xml
Cache-Control: public, max-age=3600

66
public/robots.txt Normal file
View File

@@ -0,0 +1,66 @@
# Audacity Website - robots.txt
# Allow legitimate search engines with a crawl delay
User-agent: Googlebot
Crawl-delay: 2
User-agent: Bingbot
Crawl-delay: 2
User-agent: DuckDuckBot
Crawl-delay: 5
User-agent: Yandex
Crawl-delay: 10
# Block AI scrapers and aggressive bots
User-agent: GPTBot
Disallow: /
User-agent: ChatGPT-User
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: CCBot
Disallow: /
User-agent: anthropic-ai
Disallow: /
User-agent: Claude-Web
Disallow: /
User-agent: Bytespider
Disallow: /
User-agent: PetalBot
Disallow: /
User-agent: Sogou
Disallow: /
User-agent: SemrushBot
Disallow: /
User-agent: AhrefsBot
Disallow: /
User-agent: MJ12bot
Disallow: /
User-agent: DotBot
Disallow: /
User-agent: BLEXBot
Disallow: /
User-agent: DataForSeoBot
Disallow: /
# Default: allow everything, but slow down
User-agent: *
Crawl-delay: 5
Sitemap: https://www.audacityteam.org/sitemap-index.xml

View File

@@ -13,11 +13,11 @@ const videoPromos = getFilteredPromos(Object.values(promoData), {
>
<div class="flex flex-col md:flex-row gap-12 md:gap-16">
<div class="w-full md:w-1/2">
<SplitFeaturedVideo client:load promos={videoPromos} slot="1" />
<SplitFeaturedVideo client:visible promos={videoPromos} slot="1" />
</div>
<div class="w-full md:w-1/2">
<SplitFeaturedVideo client:load promos={videoPromos} slot="2" />
<SplitFeaturedVideo client:visible promos={videoPromos} slot="2" />
</div>
</div>
</div>