This post is going to walk you through what a session and cookie is, how it works, and how they effect the speed of your WordPress site on page.ly.
What are Sessions?
Sessions can be thought of as digital name tags. When you visit a website, that website may want to assign you a name tag so the website can react according to you. It can also be used to store some information about you like preferences. Sessions are unique to the you, the user.
- An easy example is when you visit a news website and it loads stories based on your city or state. The website is reading your IP information, creating a session to store that in and then loading content based on the geographic preference.
- Another example is a shopping cart. When you add items to your cart, the website is likely saving that data into a session so as you navigate around the site your shopping cart contents go with you.
What is a cookie?
Does WordPress use Sessions?
No, not natively. WordPress is ‘stateless. It acts the same regardless of the end user. When you login to WordPress it does store a cookie, so it knows you are logged in and can show you the correct screens.
However, some plugins and themes you use with WordPress utilize sessions.
How Do I know if my site is using Sessions/Cookies?
An easy way find put is to use the cookie inspector in Firefox. Under Preferences > Privacy, look for the remove individual cookies link. Click that and you will see all the cookies in your browser. You can clear them all, visit your page again and watch if it is setting any cookies.
You will see that the cidmcorp.com site in this screenshot is setting 6 cookies. 1 is PHPSESSID which typically is the default name of the cookie used to store a SESSION ID, and the other 5 are analytics or ad code.
Typically if you see a PHPSESSID cookie, the site is using sessions.
So this site is using Sessions and Cookies.
How do Cookies and Sessions affect caching and load time?
Since Sessions are typically created to identify unique users, we dont want to serve a cached page to them or else they may see content meant for someone else. So each request bypasses caching. This typically is true for Varnish, and cache plugins like W3 Total cache and WP Super Cache.
Therefore each request using a session does not benefit from any caching or acceleration on our system.
Our system is designed to pass on certain cookies like when you are logged into WordPress, and to cache nearly everything else.
So how do I make my site the fastest loading site ever?
To take FULL advantage of our caching system, you need to limit plugin and themes that may be creating sessions. Cookies are not too big a deal as we ignore 90% of them anyways, but we have to respect sessions for shopping carts and such.
If you have determined your site is using sessions and/or PHPSESSID cookie and dont have a specific need for it (shopping cart, location aware data) you should look at disabling them.
You can search your plugin and theme files for code like:
session_start(); and comment it out, or just remove the plugin.
We are happy to assist you as well, simply open a support ticket at and we can help you identify which plugins or theme code is doing this.
Advanced: Look into Varnish Edge Side Includes to only delineate parts of your page that need live data.
What if I have to use sessions?
Try to only start them on the pages you need them on. Rather that kicking off a new session on the homepage, see if you can do it only on the page you need sessions for, such as a job listing submission or something. This way the majority of your pageviews will still be cacheable.
The performance repercussions.
If the request is bypassing the cache layers it lands on the webserver, and the webserver has to do the full load of WordPress, MySql queries and output generation every time. Each page.ly plan has different allocations of resources, so on a $24 plan this process is going to be slower then on a $149 plan.
All plans are front-loaded with Varnish to serve cacheable pages.
The speed difference between the two is pretty dramatic.
- Non-cacheable request time can vary between .8 seconds to 10+ seconds depending how ‘heavy’ your WordPress site is.
- Requests from varnish load in .1 to .2 seconds, always.