Skip to content

Commit e53815c

Browse files
purge only URL, async
1 parent 8de77de commit e53815c

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

includes/purge-bunny-cdn-cache.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
function purge_cache_for_url(string $url)
99
{
10-
$request_url = 'https://api.bunny.net/purge?url=' . urlencode($url);
10+
$request_url = 'https://api.bunny.net/purge?url=' . urlencode($url) . '&async=true';
1111

1212
$response = wp_remote_post($request_url, [
1313
'timeout' => 10,
@@ -52,5 +52,4 @@ function purge_cache_for_url(string $url)
5252
}
5353

5454
purge_cache_for_url($permalink);
55-
purge_cache_for_url(home_url('/sitemap.xml'));
5655
});

includes/set-cache-headers.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
return $headers;
1515
}
1616

17+
$url = trim($_SERVER['REQUEST_URI'] ?? '');
18+
1719
// never set cache headers for logged-in users
1820
if (is_user_logged_in()) {
1921
$headers['Cache-Control'] = 'must-revalidate, max-age=0, private';
@@ -23,7 +25,7 @@
2325
$headers['Cache-Control'] = 'public, s-max-age=3600, max-age=300';
2426

2527
// cache feeds and XML files (ie sitemap) for 1 day (shared) or 1 hour (browser)
26-
} elseif (is_feed() || str_ends_with($_SERVER['REQUEST_URI'] ?? '', '.xml')) {
28+
} elseif (is_feed() || str_ends_with($url, '.xml')) {
2729
$headers['Cache-Control'] = 'public, s-max-age=86400, max-age=3600';
2830

2931
// cache all other pages for 30 days (shared) or 1 hour (browser)

0 commit comments

Comments
 (0)