Questions tagged [cache]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
40
votes
2answers
4k 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 ...
25
votes
1answer
4k 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?
22
votes
1answer
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 ...
18
votes
4answers
2k 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 ...
13
votes
1answer
6k 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 ...
11
votes
4answers
6k 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?
11
votes
3answers
3k 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 ...
9
votes
2answers
494 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 ...
9
votes
2answers
1k 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 ...
9
votes
1answer
423 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 ...
9
votes
2answers
7k 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 ...
9
votes
1answer
971 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 ...
8
votes
2answers
3k 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?
7
votes
3answers
2k 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 ...
7
votes
2answers
2k 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 ...
7
votes
3answers
662 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 ...
6
votes
1answer
1k 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 ...
6
votes
1answer
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 ...
6
votes
2answers
443 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 ...
6
votes
1answer
581 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 ...
6
votes
1answer
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 ...
6
votes
1answer
1k 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?...
6
votes
1answer
407 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 ...
6
votes
1answer
392 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 ...
5
votes
5answers
3k 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 ...
5
votes
1answer
895 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 %} ...
5
votes
1answer
15k 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, ...
5
votes
2answers
681 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 ...
5
votes
1answer
188 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 ...
5
votes
1answer
172 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 ...
4
votes
1answer
510 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 ...
4
votes
3answers
886 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 ...
4
votes
1answer
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 %}...
4
votes
1answer
134 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 "...
4
votes
1answer
555 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, ...
4
votes
3answers
4k 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 ...
4
votes
2answers
761 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://...
4
votes
3answers
698 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 ...
4
votes
1answer
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 ...
4
votes
1answer
527 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 ...
4
votes
1answer
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, ...
4
votes
1answer
273 views

Cached entries and postDate / expirationDate [duplicate]

How does the {% cache %} tag handle a situation where an entry reaches its post date or expires?
4
votes
1answer
558 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 ...
3
votes
2answers
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 ...
3
votes
3answers
2k 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 ...
3
votes
2answers
453 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 ...
3
votes
1answer
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, ...
3
votes
2answers
754 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 %...
3
votes
2answers
2k views

Manually clean database cache

Is it possible to manually clean the database caches for templates? Doing it from the CP becomes stuck.

1
2 3 4 5