Questions tagged [cache]
The cache tag has no usage guidance.
263
questions
0
votes
2
answers
69
views
Re-using element queries in templates, where and how when using native Cache tags?
I am looking for a bit of support and guidance with caching.
Specifically where to place queries, how to re-use them and structure this across a project.
So the current project has no caching at all ...
1
vote
1
answer
34
views
Blitz cache and user fields
We use user accounts with custom fields in the control panel to allow our staff create and edit a front-end staff profile. We have over 1000 users who do this regularly.
The issue I have with blitz ...
1
vote
1
answer
41
views
Blitz cache randomly deleting
I run blitz cache with the "clear cache regenerate manually or organically setting". We have a big site with over 7000 entries, and this works best as the entire site can be cached and it's ...
1
vote
1
answer
24
views
Event after Cache Clear
I couldn't find a event that is triggered after clearing the cache. Is there one that I didn't see or is there another way to execute a controller action after the cache is cleared? It only concerns ...
1
vote
2
answers
29
views
Clear template cache from inside of a plugin
Is there a way to clear the template cache via a plugin? I didn't find a way to only clear the template cache and keep the rest of the cache intact. As far as I know there is also no fitting CLI ...
1
vote
1
answer
32
views
Ajax call returns 400 error after enable Blitz cache
I'm not sure if this happens due to the Blitz cache.
In Craft CMS 5:
In the head:
<meta name="csrf-token" content="{{ craft.app.request.getCsrfToken() }}">
<meta name=&...
1
vote
2
answers
91
views
Recreate {% cache %} content without clearing first
We have a setup where we use Craft's {% cache %} tag to improve performance of certain computing-cost-intensive pages.
The expected way to do this is by using the {% cache %} tage and probably improve ...
2
votes
1
answer
29
views
Can I empty the storage folder when migrating a Craft CMS site?
I am moving a Craft CMS to new webhost and followed this instruction. I read in another Stackoverflow post and also on this page that the /storage folder mainly contains cached, temporary files. Is it ...
1
vote
2
answers
41
views
ImageTransform Focal Point Cache Busting
I have a Question about image transform focal point behavior.
Twig templating or with php. Getting the url of an asset with a transform $asset->getUrl('transformer')
If i am understanding the ...
0
votes
2
answers
41
views
Craft 2 Caching RESTful API Results Displayed On Page
I have made a php plugin in Craft 2 which calls a RESTful API and displays the results on the template. The data is returned at about 8 seconds. I've surrounded the call to the plugin on the ...
1
vote
1
answer
108
views
Craft CMS 3.8 - Field not found after changing entry type, but then is found after running again
I'm currently using migrations to change/swap content. On certain entries, there are assigned category fields attached to specific entry types. I am consolidating all of these to a single category ...
0
votes
0
answers
118
views
SQLSTATE[HY000]: General error: 5 Out of memory (Needed 418490224 bytes)
I'm building a webtoon with CraftCMS 4 but facing this issue: SQLSTATE[HY000]: General error: 5 Out of memory (Needed 418490224 bytes)
Screenshot: https://i.sstatic.net/oMKud.png
All entries are a ...
1
vote
2
answers
579
views
Blitz not updating cache on multi-sites
I have been using Blitz caching on a Craft (v3.759) site and it is working well. I recently added a second site using Craft's multisite capability. This second site uses a different domain and I have ...
1
vote
1
answer
324
views
Redis setup for a Craft 4 site - error OOM command not allowed when used memory > 'maxmemory'
I have set up Craft 4 to use Redis for all its cache (due to hosting requirements) I have worked my way through the docs and some SE posts plus Andrew's blog post. Everything seemed to be working ...
1
vote
1
answer
123
views
Do cache queries work on relation fields and global sets?
I see in the docs I can do something like:
{% set entries = craft.entries
.sectionId(2)
.with(['someRelationField'])
.cache(0)
.all()
%}
and this will cache the query indefinitely because of ...
0
votes
1
answer
54
views
Optimise this repeated entry query? (which groups entries by a shared field value)
This loop containing a query is (surprise surprise) proving very intensive.
There is also a second very similar query on the page to get all of the events related to this year and list them by just ...
0
votes
1
answer
437
views
Blitz: Exclude URL with specific query parameters
I have a blog listing page, which I would like to cache using Blitz.
However, when a user searches the blog (/blog?search=something) I'd like to load the un-cached version.
I'm using server rewrite to ...
1
vote
1
answer
157
views
Recommended Redis data eviction policy for Craft CMS
I have recently switched from memcached to Redis. The cache, session, template caching and mutex is now using Redis on a project. While Redis generally gets managed by Yii/Craft CMS, Redis features a ...
3
votes
2
answers
817
views
Recommended caches to clear after server deployments?
Craft has this article about deployment best practices: https://craftcms.com/knowledge-base/deployment-best-practices
It also states that you might want to clear caches after deployments, which is of ...
1
vote
1
answer
183
views
Craft creating over 250.000 cache files
My Craft CMS 3.7.38 is creating over 250.000 almost identical cache files inside the /storage/runtime/cache/-folder. Because the website isn't even a frequently used big platform, I have no idea why ...
2
votes
1
answer
218
views
Disable template cache globally based on condition
I'm looking for a way to disable the template cache ({% cache %} tags) for the entire request based on a specific condition (not just based on the current environment). In this case, the condition is ...
3
votes
2
answers
205
views
How do you deal with random class and cache?
I recently started using tailwindcss and I generate random classes via the function random() and get "text-nature", "bg-nature", bg-nature-light", "text-culture", &...
1
vote
1
answer
266
views
Upgrading to 3.7.26 causes tempnam() error from twig's FilesystemCache.php
I am upgrading a Craft project that I have been neglecting for a little bit too long. I am upgrading to 3.7.26 from 3.4.25; on top of this, I am upgrading from PHP 7.1 to PHP 7.4.
I'm also updating a ...
0
votes
0
answers
20
views
How can I stop a user registration thank you page being cached in Craft 2
I seem to have an issue with a thank you page on user registration in craft 2. The thank you page gets passed a modified users id which is shown to the the registrant.
However some odd occasions have ...
1
vote
1
answer
95
views
file based cache and runtime files in load-balanced environments
We are currently setting up 2 Craft webservers behind a load balancer with sticky sessions.
What I am wondering:
Is there any need, that
the file based cache needs to be somehow switched to a shared ...
1
vote
1
answer
227
views
Cache Excesive Assets Size
I have only been using Craft 3 for a short time and I am currently the webmaster of a too big news site. I just checked that the /storage folder is almost 80GB in size. All the size is in the /storage ...
1
vote
1
answer
196
views
New assets field not showing up for some users
I've added an assets field to an existing channel that shows up fine for me on both the new entry and editing existing entries, but it's not showing up for some users. I've cleared cache in Craft ...
1
vote
1
answer
30
views
Is cached content served while the cache is regenerating?
I've always been unclear on this (it would be nice to include in the documentation). Let's say I use a cache tag like so:
{% cache for 1 hour %}
After an hour has passed, will the next user to load ...
0
votes
0
answers
170
views
Automatic Asset Cache Clear
I have a large website that various users need to upload important documents (assets) to frequently. I need to have the Craft asset cache clear every time a new asset is uploaded. The other option I'...
1
vote
1
answer
49
views
.env.sh in craft-scrips
I'm having trouble setting the variables of the env.sh file for craft-sctipts.
I getting an error: File /common/defaults.sh is missing, aborting. when I try to clear the cache using a cronjob pointing ...
1
vote
1
answer
110
views
Additional code to run when cache is busted(entry added/updated, etc)
I'm using Craft Pro 3.6 in Headless mode. I've found that caching the GraphQL responses on the frontend server dramatically speeds up our load time, even with enableGraphQlCaching turned on.
What I'd ...
2
votes
1
answer
2k
views
400 bad request ("Unable to verify your data submission.") when Adding product to cart
When a user tries to add something into the cart the following error appears:
400 bad request ("Unable to verify your data submission.")
2021-02-23 09:08:42 [-][-][...
0
votes
0
answers
301
views
Cache not working
I'm having troubles with my site being super slow. It seems like caching isn't working. When I upload the site to a different server, everything seems fine.
When I empty the template cache and load ...
3
votes
1
answer
526
views
How to cache and serve different data to different users using Blitz?
What strategy should I take when I want to serve different data to different users with (Blitz) cache? Logged in users get one set of prices (that can vary depending on their price group memberships), ...
0
votes
1
answer
152
views
currentUser gets cached
I'm having a problem with navigation that seems to get cached.
If the page is loaded by someone who is not logged in, it shows the login button in the navigation (and it should).
Once the user is ...
1
vote
2
answers
264
views
Why is Craft loading jQuery via cpresources? And can I stop it?
I've been doing some performance checks on a website I'm building, and noticed that jQuery 3.5.1 is being loaded via cpresources:
Why is it doing this? And can I stop it? I'm already loading jQuery 3....
2
votes
1
answer
171
views
Craft CMS: Data too long for column 'cacheKey' at row 1
We have Craft CMS v3 using multi-sites.
We are using cache to cache whole pages based on the absolute URL as some URLs have query parameters which seem to be ignored when not using a key. So the ...
1
vote
2
answers
442
views
Prevent caching from inside of the cache tag
Does anybody know, if it is possible to prevent caching from within the cached code/content?
Something like:
{% cache ... %}
...
{% do notCache %}
...
{% endcache %}
Why? Because if there is a ...
3
votes
1
answer
949
views
How does the new caching works (3.5+)
Just upgraded to Craft 3.5+ the pages are cached (instant load on a 2nd run) but the templatecaches and similar tables are empty. How exactly does it work now? How do I flush cache for 1 specific page ...
2
votes
1
answer
290
views
Clear cache tool missing
I'm trying to clear templates cache. The Craft CMS 3 documentation says:
You can also manually clear all of your template caches from the Settings page, using the “Clear Caches” tool.
When I go into ...
0
votes
0
answers
78
views
How to stop caching entries/templates?
I have a dynamic form that creates entries in Craft 3 Pro. These entries are displayed in a "Profile Page" for each user, but it only shows the newly created entries after hitting refresh 2 ...
0
votes
0
answers
81
views
Paginate and Cache Together and SEOmatic helpers
I am struggling to get this working correctly.
If I keep the element queries outside the cache tag then this naturally stops the cache being broken and so is not a viable option. However, when I put ...
1
vote
1
answer
142
views
I am getting this message when creating a new project
Cannot create cache directory /home/cmnd/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
0
votes
0
answers
403
views
Multisite with unique domains not working with Forge config
I have a live install with a primary domain of https://marketing.vessul.co/ which works great.
When I've added another site to this install and it's location is another folder such as /extra-site it ...
1
vote
1
answer
216
views
How to prevent cache busting (preferably on a single section)?
I have a template that displays 1,100 entries as dots on a zoomable/searchable map. The query is cached and it performs beautifully. As expected, if I edit any of those entries the cache is busted and ...
1
vote
1
answer
258
views
How to prevent Craft from injecting scripts in the page?
I have a website that resides behind a static cache. Today, I realised that some of the cached pages contain this bit of JavaScript at the end:
<script type="text/javascript">
/*<![CDATA[*/
(...
1
vote
1
answer
457
views
Uploading Asset Doesn't Clear GraphQl Cache with VueJS/Axios
Context:
I have a VueJS method that uses a form and Axios to upload an asset to an entry's asset field.
The method successfully uploads the asset to the entry, and I can prove that fact via the ...
1
vote
0
answers
44
views
How to append current version to post URL - versioning a post
I'm middle of a PWA app and one of the problems facing is versioning, once the post cached using Service Worker and if any change amended(ex: if it is an event post, the event end date may be extended....
1
vote
1
answer
226
views
Separate cache per user or user group in Blitz cache
We're using Blitz cache for a client website. Works fine.
Now we need to introduce variable content for different users (based on user groups)
Is it possible to have different cached versions per ...
1
vote
1
answer
90
views
Craft 3 Cache Busting for Pending Entries
So in Craft 2 the following code was required to cache bust if an entry was set to pending or post at a future date.
{% set firstPending = craft.entries({
section: 'projects',
status: 'pending',
...