What is the different between Redis and Memcache or Memcached?

Excellent question! Unfortunately, there is no short answer. You'll probably want to do some reading. However, Redis is usually easier to setup and configure. Memcache and Memcached are effectively the same thing, but are two different things by two different authors. Not at all confusing, huh?

Given the choice, we'd recommend Redis.

What type of cache should I use? I don't understand the difference between static and fragment caching.

If every visitor to your site is allowed to see the exact same content, regardless of login status, session, cookies, etc, then static caching is the way to go. It completely bypasses ExpressionEngine and delivers the fastest page load times. In some cases you can get < 0.10 second response times or faster.

If your site heavily relies on member logins, dynamic data, or information that is unique to each visitor, then fragment caching is the way to go. For example, if someone logs in to your site and you display their username or profile icon indicating they are logged in, or if you are selling a product and have a checkout page that is unique to the user, then you want fragment caching. You can wrap large portions of your content in a fragment tag, then use the escape and pre-escape tags for the dynamic content. In the case of a store where you are selling products, you could use static caching for the product pages, then add an URL Ignore to ignore the /checkout or /cart sections of the site.

If you wanted to get more advanced, you can use static caching with hole punching. Which means you load a fully cached static page, but use JavaScript to load user specific content when the initial page load is complete. This technique outside of Speedy's documentation and support, but if you're feeling adventurous there are plenty of resources online to get you started.

What is the difference between Static caching, and Redis, with Static caching enabled?

The Static driver saves all items as files on your web server, which works great for a single web server, and if Redis is not available to you. However, if you have multiple web servers, it is recommended to use Redis with Static enabled. This is very similar to Static caching where the entire contents of your pages are saved in Redis, but is better for multiple server enviroments because each server is using the same cache storage. Since the Static driver saves files to the server, you will have multiple instances of the same cached item. For example, if Jane comes to your site, and the load balancer sends her to server A, then John comes to your site and is sent to server B, John will not see the cached page that was created for Jane. Cache clearing also becomes more difficult because you will need to login to the control panel on each server to clear cache items.

Can I use an {embed} tag inside of an {exp:speedy:fragment} tag?

Yes, absolutely. The embed tag will be parsed and cached as part of the fragment content.

Can I use ExpressionEngine's {layout} feature with Speedy?

Yes, but it requires a bit of a work around. Check out the Tags documentation page.

Can I cache pages that use query strings, such as ?category=fruit

Yes you can, but you must add all the query string keys, in this case category to the speedy_query_cache_whitelist config option. For example:

$config['speedy_query_cache_whitelist'] = [

The reason a white list is required is to prevent caching the same page multiple times. For example, many sites rely on Google Tag Manager or other similar services, or use query string parameters that are only used by JavaScript. If the requested URL is site.com?category=fruit&utm_referrer=SomeVendor, then you will end up with the same page content cached twice. Bots and evil people also scan websites for vulnerabilities using query string parameters. If you pay attention to your server logs, you'll probably see a lot of requests to bogus pages. Now imagine every one of those bogus requests get cached separately, even though the content of each page is identical. For this reason, whitelisting query string parameters is the preferred and supported route. This method has been tested and proven based on over 2 years of use in production.

Last updated