Skip to main content
8 votes
Accepted

Are there any file-based static cache options for Craft CMS?

Someone has recently developed a standalone static HTML caching plugin for Craft CMS which does similar to what you're after: HTML Cache plugin for Craft CMS This Craft plugin will generate static ...
Tim Everts's user avatar
7 votes
Accepted

Force browser to download latest CSS file

There are several plugins that can do this. With my plugin Stamp, you can add a timestamp to the filename or path in the following formats: <script src="/assets/build/js/1399647655/scripts.js"&...
André Elvan's user avatar
  • 7,288
6 votes
Accepted

DeleteStaleTemplateCaches taking forever

This is a side-effect of Craft's amazing automagical cache system. :) Check out my answer on this question for an explanation of what happens. Regarding your question of how to fix this, part of the ...
André Elvan's user avatar
  • 7,288
6 votes

Force browser to download latest CSS file

I tend to use a config.php variable (called assetVersion) for the production site, and just generate a random value for the dev site using Twig's random function. Looks like this: <link rel="...
Ian Ebden's user avatar
  • 894
5 votes

Is it possible to cache variables using the {% cache %} tag?

You can accomplish this by using the set/endset tags to create a variable from the cached output: {% set finalVariable %} {% cache %} {# heavy lifting (like queries) here #} {# ...
Aaron Waldon's user avatar
5 votes
Accepted

How to omit certain tag from (% cache %)

Unfortunately, the vanilla {% cache %} tag doesn't have a way to escape or ignore certain content. The obvious workaround is to have more than one {% cache %} tag, where the content that shouldn't be ...
Mats Mikkel Rummelhoff's user avatar
5 votes
Accepted

How to cache a Guzzle Http request?

You can either cache it globally or in the session // your cache key $key = 'akey'; $cache = Craft::$app->getCache(); $value = $cache->get($key); // check if there is a valid value that is not ...
Robin Schambach's user avatar
4 votes

Cache issues making site super slow in production but not in dev mode

For others that might be facing an issue similar to this – we found that our Craft site was gradually getting slower and slower over a period of several days, despite using the {% cache %} tag. When ...
Simon East's user avatar
4 votes

Delete Stale Template Caches tasks much larger in Production than Staging

First, this is perfectly normal. :) Have a look at Brandons explanation here on how the cache tag works. If the element was added or modified, it queues up a new “Delete Stale Template Caches” ...
André Elvan's user avatar
  • 7,288
4 votes
Accepted

What's the difference between setting cache with {% header %} tag and {% cache %} tag?

The header tag sets an HTTP response header, which may be used to (among other things) tell the browser that the response content is "cacheable". The cache tag tells Craft to cache the generated HTML ...
Stephen Lewis's user avatar
4 votes
Accepted

Using cache tag on array outputs nothing

The {% cache %} tag is only designed to do one thing – to capture output (e.g. HTML) and store that output to the database, so that the next time Craft encounters that particular cache tag, it can ...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

Static page caching using Nginx FastCGI Cache with CraftCMS

The issue had something to do with PATH_INFO. Adding 'usePathInfo => true' in general.php fixed the issue. Here's the detailed explanation from Craft docs: https://craftcms.com/support/enable-path-...
Anya Dit's user avatar
  • 366
4 votes
Accepted

Craft incredibly slow site performance

It turned out this was the culprit. Craft was doing a deprecationerrors query (https://github.com/craftcms/cms/issues/2539). Turning devMode to false fixed this. Hope this helps someone...
Hassan Mahmood's user avatar
4 votes

Recommended caches to clear after server deployments?

I recommend clearing all caches on deploy via clear-caches/all. Caches should not be used to mask performance issues, they are used to solve concurrency & scaling, by holding onto data that doesn'...
andrew.welch's user avatar
  • 11.6k
3 votes
Accepted

Is cache condition necessary to stop HTML being inserted into database cache?

No, there is a better way to do this. Set the enableTemplateCaching config value to false. 'enableTemplateCaching' => false, With that setting disabled, all caching will be skipped. // Won't be ...
Lindsey D's user avatar
  • 24k
3 votes

How can I Prevent CSRF Tokens from being Cached?

Further to Ben’s answer, it may be inconvenient to set and replace every time the partial with the CSRF token is required, in which case the replacing can instead be done in one go for each page’s ...
David Oliver's user avatar
3 votes
Accepted

Define elements that bust cache on save

Hard to know for sure without seeing some plugin code, but my guess is you'll want to use the TemplateCacheService's includeElementInTemplateCaches similar to how BaseTemplate's ...
Brad Bell's user avatar
  • 67.5k
3 votes

Is there a way to force Assets to redo transforms?

I found that a really easy way to rebuild transitions is to simply change the transform settings in the craft admin interface. For example maybe your transform is to 400 pixels, change it to 200 ...
Clark's user avatar
  • 31
3 votes

Expected performance benefit of using a non-file CacheMethod (Redis, Memcache)

How many servers do you have? Redis and Memcached are most beneficial/intended for a multiple server setup so if you only have one server, there's probably other/betters thing to worry about. (Best ...
RitterKnight's user avatar
  • 6,582
3 votes
Accepted

Expected performance benefit of using a non-file CacheMethod (Redis, Memcache)

As with most performance related questions, the answer is "it depends". :) Apps like Redis and Memcache store their key => value stores in memory as opposed to disk-based file caching. Accessing ...
Brad Bell's user avatar
  • 67.5k
3 votes
Accepted

Using setExpires on returnJson

If you're running Craft CMS 2.6.2783, you can pass in an 'expires' key to the optional $options 2nd parameter of returnJson with the value set to the time in seconds that will be passed to the cache ...
Brad Bell's user avatar
  • 67.5k
3 votes

Are there any file-based static cache options for Craft CMS?

You can also implement FastCGI Cache for static page caching pretty easily; check out: Static Page Caching with Craft CMS
andrew.welch's user avatar
  • 11.6k
3 votes

Is it possible to clear caches and re-index assets programattically?

Updated Craft version 3+ now has console commands built in that can handle these tasks. $ php craft clear-caches/all $ php craft index-assets/all See documentation for Console Commands in 3.x or ...
Alex Roper's user avatar
  • 2,642
3 votes
Accepted

Caching and TTFB with Craft

This isn't an issue with Craft, from the POV that the TTFB should be pretty consistent. How are you testing it? My guess would be that the issue is with your hosting. These two articles may help you:...
andrew.welch's user avatar
  • 11.6k
3 votes
Accepted

'cacheDuration' => false, sets cache file expiration date to 1 year

Yeah, it's slightly awkward. First off it should be '0', instead of false if you want it to cache indefinitely (documentation bug, just fixed). It's slightly awkward because the cacheDuration config ...
Brad Bell's user avatar
  • 67.5k
3 votes
Accepted

Why if I change ie. drop down value, all entries needs to be resaved to take changes? How can I prevent it?

Dropdown fields (and other simple option-based fieldtypes such as Radio Buttons, Checkboxes and Multi Select) are pretty dumb. By design, whenever an Entry with a Dropdown field is saved, Craft ...
Mats Mikkel Rummelhoff's user avatar
3 votes

How to Cache Globally Except for One Page

You could add a variable like globalCacheDisabled and {% cache globally using key 'entry_' ~ entry.id ~ '_elements' unless globalCacheDisabled %} and use a {% set globalCacheDisabled = entry....
Max Strebel's user avatar
3 votes

Security test generated large compiled_templates directory, site outage

I don't have specific answers to your questions, but that's mainly because I feel there are some clarifications and observations that I think might be more helpful. The thread you linked to is ...
Brad Bell's user avatar
  • 67.5k
3 votes

Cache and Pagination not working

Based on the code you posted on pastebin, it seems like the problem is that you have your pagination outside of the cache tags (assuming this was the case when you had caching implemented). And, I'm ...
André Elvan's user avatar
  • 7,288
3 votes
Accepted

Craft CMS 3 - Redis Sessions cause error

@boboldehampsink to the rescue: https://github.com/craftcms/cms/issues/3428 Update: This article covers things really well. https://nystudio107.com/blog/the-case-of-the-missing-php-session php ini ...
Tim Kelty's user avatar
  • 3,081

Only top scored, non community-wiki answers of a minimum length are eligible