Taming Dexerto.com
ESports is popular.
Constant high traffic with peaks between 15:00 and 22:00
{% cache globally using key "advert-1-" ~ currentSite.id ~ "-" ~ category.id ~
"-" ~ (craft.app.request.isMobileBrowser(true) ? 'mobile' : '') for 120 seconds %}
{% set expiryTime = expiryTime ?? 60 %}
{% if currentUser or preventAllPageCaching %}
{% header "Cache-Control: no-store, no-cache, must-revalidate" %}
{% else %}
{% set expiry = now|date_modify('+' ~ expiryTime ~ ' seconds') %}
{% header "Cache-Control: public, max-age=60, s-maxage=" ~ expiryTime %}
{% header "Pragma: cache" %}
{% header "Expires: " ~ expiry|date('D, d M Y H:i:s', 'GMT') ~ " GMT" %}
{% endif %}
Event::on(
Elements::class,
Elements::EVENT_AFTER_SAVE_ELEMENT,
function (Event $event) {
$entry = $event->element;
if ($entry->refHandle() === 'entry') {
try{
self::$plugin->cloudflareService->invalidateForEntry($entry);
}catch(\Exception $e){
Craft::$app->session->setError($e->getMessage());
}
}
}
);
Q's?
@mattgrayisok