Matt
Completely unqualified to be an entrepreneur. But it's the taking part that counts, right?
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
By Matt
Dexerto.com receives one million unique hits per day and runs on a Craft CMS back-end. To stop the site from constantly crashing I implemented a few changes to get things back under control...
Completely unqualified to be an entrepreneur. But it's the taking part that counts, right?