Speed difference with Cookies

The past week I have been working on SMYLN.com and tried to squeeze the rest of speed out of the setup. The pages are now distributed with Cloudflare AND Amazon Cloudfront and I have optimized the render path of the HTML to reach high numbers on Google Pagespeed Insights.

Still I was some 90-120 milliseconds away from the response times of the big players. The only thing I could think of to go the last mile: SESSIONS and COOKIES…

Before modifications I saw this in the developer console… fairly in the same ballpark the whole time: ca. 100 ms.

So, most of the time 100+ milliseconds before the server even responded. And that at night, when the masses do not surf too much. After that, I modified the session handling and saw that: 39ms.cookie-less speed

If you look closely: same URL, same https request on https://9.smyln.com/ and now we are, where I wanted that stuff to have.

An important aspect is, that the subdomains are delivered by Amazon Cloudfront and if there is no COOKIE and no SESSION, the outlets of Amazon deliver a static, cached page.

That difference is significant and an important trick to get the rest out of your servers. Just for the sake of it, I did the same reload orgy on google.com and saw: 82ms. Yet with a page that is double in the size.

Still good numbers and something to implement for our customers.

For those of you, who do code in PHP, here a little code snippet, that expresses the approach:

if(!isset($doSession) OR isset($_COOKIE['PHPSESSID'])) {
if($doSession) {
} else {
    $myHours = 1;
    header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * $myHours)));
    header("Pragma: cache");
    header("Cache-Control: max-age=" . (60 * 60 * $myHours));
    header("User-Cache-Control: max-age=" . (60 * 60 * $myHours));

and you can see, that the $doSession is a flag, which I can use to opt-out on specific pages. You get the idea.

Leave a Reply

Your email address will not be published. Required fields are marked *


Time limit is exhausted. Please reload CAPTCHA.