Skip to main content

Questions tagged [cache]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
42 votes
2 answers
5k views

What are the best practices for using the {% cache %} tag?

I started using the {% cache %} tag and would like to know what the best practices are: . Regarding performance: For example does it make sense.. ..to cache the whole template, or is it better to ...
Victor's user avatar
  • 8,396
25 votes
1 answer
5k views

Generating pending image transforms stuck in process

In the CMS the progress indicator for tasks is stuck and not completing its jobs. What can I do to resolve this?
a-am's user avatar
  • 2,857
22 votes
1 answer
2k views

How does template caching work?

The {% cache %} tag is quite powerful, and can be used to greatly increase the performance of templates. But ultimately the whole thing is still pretty mysterious. I can see three tables in the ...
Lindsey D's user avatar
  • 24k
18 votes
4 answers
3k views

Cache invalidation to automatically update all cached template content?

I am using the cache tag in my templates. How can I assure that a site visitor always gets the data directly from the cache and never has to wait for it to be generated? My cache gets invalidated ...
carlcs's user avatar
  • 36.3k
15 votes
1 answer
10k views

What are the cache options available to a Craft installation?

Reading the Craft docs and other related questions on Stack Exchange there seems to be a lot questions about caching, what it does under different scenarios and how to best utilize it. Is there an ...
Brad Bell's user avatar
  • 67.5k
11 votes
4 answers
8k views

Can I disable template caching for local development?

Can I disable template caching for local development? For example: setting a environmentVariable in a config file? Or is this possible in the future?
sneeky's user avatar
  • 415
11 votes
3 answers
4k views

Is there a way to force Assets to redo transforms?

Client has uploaded a number of severely badly lighted photographs for a 'staff' section of a site and these all have had a 'staffThumb' transform applied to it on the sites pages. I corrected the ...
erwinheiser's user avatar
10 votes
3 answers
4k views

Why does Craft set no-cache headers for all requests?

Craft seems to be setting headers to tell the browser not to cache anything it serves, which seems bad. Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Why it do dat?
Tim Kelty's user avatar
  • 3,081
10 votes
2 answers
11k views

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

When migrating a Craft site, I'm used to... deploying files checking my config, tweaking as necessary loading a database backup running "Update Asset Indexes" and "Clear Caches" from the control ...
Matt Stein's user avatar
  • 4,006
9 votes
2 answers
601 views

Why does my base template never reload?

I use template inheritance: In _layout.html every other template is loaded with {% block content %}{% endblock %} The problem: _layout.html never reloads. I changed the CSS path in the head tag of ...
KSPR's user avatar
  • 3,786
9 votes
2 answers
2k views

How do I cache with the ElementAPI plugin?

I'm replacing some templates with the ElementAPI plugin. In my templates, I would use the cache tag, and rely on Craft to handle invalidation when the elements changed. How can I achieve a similar ...
Tim Kelty's user avatar
  • 3,081
9 votes
1 answer
479 views

Caching not working on page with asynchronously loaded asset transforms

I'm using PictureFill on a large page, containing many image transforms, that doesn't seem to be caching despite most of the page being wrapped in {% cache %} tags. When I view the page after several ...
cmal's user avatar
  • 815
9 votes
1 answer
1k views

Is there a way to override the template caching system?

We're in the process of building a restfull backend in craft. We had sluggish response times due to the amount of queries done by craft on a an entry listing. Each entry had about 3 levels of nesting ...
pythic's user avatar
  • 569
7 votes
3 answers
3k views

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

Is there an option for storing the pages generated by Craft CMS as flat, static HTML files? The model used by static driver from ExpressionEngine's CE Cache add-on works pretty well: Each page ...
Nick Benson's user avatar
7 votes
2 answers
3k views

How to disable template caching? devMode isn't doing it

I'm trying to disable template caching in my development environment. I've tried a few things but thus far nothing has worked. I had thought that just setting devMode to true in the config would do ...
thechrisroberts's user avatar
7 votes
3 answers
857 views

Is it possible to use environment variables as the cache duration?

I'm trying to set a cache duration as an environment variable. I set up various environment variables and know they are being referenced correctly in my templates because I can print out the values ...
Wes Rice's user avatar
  • 640
6 votes
1 answer
2k views

Adding active class to globally cached navigation

I have a structure which controls my main site navigation. It's the same across the site so it is best to cache globally as opposed to a cache of the navigation or every url. The last answer on this ...
mmc501's user avatar
  • 1,789
6 votes
1 answer
2k views

Varnish 4.x and Craft

Is there any vcl file to use with Craft? I saw here an amazing answer about Varnish and Craft and there is a 3.x configuration file but i need a newer one for Varnish 4 and i don’t know Varnish ...
mbalparda's user avatar
  • 647
6 votes
2 answers
475 views

Cache tag won’t cache in a template

The image tag shown below prevents my {% cache %} tag from caching the loop it's in. If I remove the image tag or change the data-resource attribut to a normal src, it works fine. The class="lazy" and ...
Willhaus's user avatar
  • 201
6 votes
1 answer
724 views

Cache/ColdCache & checking for ungenerated image transforms

This issue is very similar to the following issue, but this goes a little bit further. Cache tag won’t cache in a template I have a page which is made up of hundreds of lazy loaded images similarly ...
Johan Douma's user avatar
6 votes
1 answer
1k views

How to fix "ambiguous" column error generated when DeleteStaleTemplateCaches is run?

Following up on: Deleting Stale Template Caches Failed Here's what I'm assuming is the tag throwing the error in the DeleteStaleTemplateCaches task. How would I disambiguate this? I'm not sure ...
Mark J. Reeves's user avatar
6 votes
1 answer
2k views

What's the best way to clear cached JSON responses from a third-party API?

I'm building a plugin to browse store orders via a third-party API. I make various requests to URLs that can include query parameters: /customers /orders/e8b48e72-9c7f-4d6f-91aa-2f7238bdf936 /orders?...
Matt Stein's user avatar
  • 4,006
6 votes
1 answer
474 views

How to omit certain tag from (% cache %)

How can I omit a certain tag from being cached? I have a large page with a fair few queries but halfway down I am loading in a Freeform Form field which cannot be cached. But I'd like all of the ...
Mark's user avatar
  • 741
6 votes
1 answer
509 views

What effect does nesting cache tags have?

What effect, if any, does nesting cache tags have? It seems like it would be redundant, but are there any inherent drawbacks? Recently, I can across an instance where I was using the {% cache %} tag ...
Alex Roper's user avatar
  • 2,642
5 votes
5 answers
4k views

How can I Prevent CSRF Tokens from being Cached?

We have a Craft site in which we include a partial that includes in several different places. CSRF is enabled, and we're appending {{ getCsrfInput() }} to the form. Because of the way we've set up ...
Peter Compernolle's user avatar
5 votes
4 answers
5k views

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

I'm wondering what kind of performance increase, and in what situations, I might expect from using Redis or Memcache over the default file-based caching. I know template caching always comes from the ...
Tim Kelty's user avatar
  • 3,081
5 votes
1 answer
16k views

Adding cache headers to Nginx configuation file breaks the /admin area

When I add this to my Nginx Confirguration file: location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 7d; add_header Pragma "public"; add_header Cache-Control "public, must-revalidate, ...
Jason D's user avatar
  • 1,132
5 votes
1 answer
1k views

Caching queries not working as expected

I think I am not fully understanding how caching works. Based on this answer I thought I could cache my query and then shuffle the resulting array items. So I ended up with this code: {% cache %} ...
Katrin's user avatar
  • 674
5 votes
2 answers
752 views

Can Craft handle thousands of entries and high traffic?

We are going to start an online magazine. Registered users will be able to submit new entries (articles, places, etc...). Can Craft handle thousands of entries and high traffic (Of course with ...
user avatar
5 votes
1 answer
242 views

Good practice to "Clear Caches" before you "Backup Database"?

Every time I create a database backup, I find myself instinctively clearing the cache first. My gut tells me that any cached data would be unnecessarily included in the export. Is this helpful, or am ...
Lindsey D's user avatar
  • 24k
5 votes
3 answers
798 views

Template Hook + Caching

A portion of my template is being cached, using the standard cache tag: {% cache %} Within that cached section of the template, I'm using a template hook: {% hook 'myTemplateHook' %} Within that ...
Lindsey D's user avatar
  • 24k
5 votes
1 answer
181 views

Is caching the layout wrapper template a viable option?

I've been thinking about creating the simplest possible cache solution and would like to know if this is a worthwhile option. Using the outstanding cacheflag plugin, I place the entire layout wrapper ...
mjr's user avatar
  • 1,405
4 votes
4 answers
3k views

Force browser to download latest CSS file

Is there any simple way to automatically add a version number when referencing a CSS file? Example: <link href="style.css?v=VERSION-HERE" rel="stylesheet" type="text/css"> Version could be a ...
Magnus's user avatar
  • 171
4 votes
1 answer
523 views

Troubleshooting paginated content cached globally

Looks like caching paginated content globally forces any following pages (p2,p3, etc) to just echo the same content as the first page. Using a regular cache tag works as desired, but I don't want to ...
Chase Giunta's user avatar
4 votes
3 answers
1k views

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

We have a site that is performing very poorly with very long load times and I'm guessing it may be related to caching but have no idea how/why. The site's homepage was loading very slowly while in ...
Mike's user avatar
  • 719
4 votes
2 answers
1k views

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

I would like to cache a variable and compare the cached variable with a parameter from the query string. Is it possible to somehow cache a variable ? {% cache using key "cacheId" %} {% set id = 1 %...
Marco Schuler's user avatar
4 votes
1 answer
1k views

Cacheing in PHP code for plugin

I have a plugin that makes several and potentially slow database calls that eventually return 8 Entries. Is there a way to make use of Craft's built in caching on the plugin side? Using the {% cache %}...
Aaron Berkowitz's user avatar
4 votes
1 answer
141 views

Section Single Title Caching

I have the following - {% set press = craft.entries.section('press').first() %} {{ press.title }} If I change the section title in the Sections area of the back end from something like "Press" to "...
Alex Mejias's user avatar
4 votes
1 answer
596 views

How can I mitigate caching performance issues with Craft?

I ran into problems with the performance of one of our Craft sites. This showed up as: MySQL running out of memory and crashing, because Apache was using up all the memory in backgrounds tasks, ...
khamer's user avatar
  • 281
4 votes
2 answers
1k views

Static page caching using Nginx FastCGI Cache with CraftCMS

This isn't Craft issue per se. But I was wondering if anyone can help me out. I’m trying to enable FastCGI Cache in my server. My nginx server block is coming from this helpful article: https://...
Anya Dit's user avatar
  • 356
4 votes
1 answer
2k views

When does Craft change or delete template caches?

My question is regarding template caching in Craft. I want to know when does Craft actually change the cache or delete old cache. Let's say that I am caching a chunk that just displays the entry ...
Moin Qidwai's user avatar
4 votes
1 answer
543 views

How can I time-profile the page load for a Craft request?

I would like to see how long plugins take to load, as well as other aspects of the page (loops and database requests). My webpage can take ~2-3 seconds to return the initial request. It seems high ...
Jason D's user avatar
  • 1,132
4 votes
1 answer
1k views

Cached template content not invalidating

My understanding of the {% cache %} tag is that if the content between it changes, the cache is invalidated and you see the new content. I'm having an issue where a new entry is created in section, ...
kekona's user avatar
  • 41
4 votes
1 answer
311 views

Cached entries and postDate / expirationDate [duplicate]

How does the {% cache %} tag handle a situation where an entry reaches its post date or expires?
Ian's user avatar
  • 564
4 votes
1 answer
813 views

Caching in Craft 3 causes out of memory when including grouped for loop

I have a problem with using {% cache %}in Craft 3, although the code runs fine without caching, and it works in Craft 2. I have narrowed the problem down to the following code: {% cache %} {% set ...
KSP's user avatar
  • 849
3 votes
2 answers
1k views

Resolving “Stuck” Background Tasks

Hi guys so I am having an issue with the "generating pending image transforms" being stuck. I've seen the solution listed here https://craftcms.com/support/stuck-tasks telling me to go to the ...
JeffTalbot's user avatar
3 votes
2 answers
568 views

{% cache %} always creates new cache data, never uses existing cached data

Why would the {% cache %} tag be storing a new cache every time the page loads (instead of just loading the existing cache)? Unless I'm misunderstanding how caching works, the system should never ...
Lindsey D's user avatar
  • 24k
3 votes
1 answer
2k views

Long 'Deleting stale template caches'

Is it common to have a (near)constantly running 'Deleting stale template caches' task ongoing? I commonly log in to see a task still pending several hours after the last change to the site was made, ...
Darren's user avatar
  • 433
3 votes
2 answers
2k views

Manually clean database cache

Is it possible to manually clean the database caches for templates? Doing it from the CP becomes stuck.
Florian's user avatar
  • 428

1
2 3 4 5 6