<p>I have a dynamic form that creates entries in Craft 3 Pro. These entries are displayed in a &quot;Profile Page&quot; for each user, but it only shows the newly created entries after hitting refresh 2 or 3 times. This is the code I use to fetch them:</p>
<p><strong>Craft entries loop</strong></p>
<pre><code>{% extends &quot;layout&quot; %}

{% block content %}

    {% set entries = craft.entries.section('cotizaciones').authorId(currentUser.id).orderBy('dateCreated desc').search('statusDeCotizacion:recibido OR statusDeCotizacion:enProceso').limit(null) %}
    {% set countEntries = craft.entries.section('cotizaciones').authorId(currentUser.id).orderBy('dateCreated desc').search('statusDeCotizacion:recibido OR statusDeCotizacion:enProceso').count() %}

    {% if countEntries &gt; 0 %}
        {% for entry in entries %}
            {% include &quot;...&quot; with {'active': true} %}
        {% endfor %}
    {% else %}
        NO ENTRIES
    {% endif %}

{% endblock%}
</code></pre>
<p>I've run some tests on Incognito and it seems to work a lot better, is there a default cache that I can bypass to make this process more seamless?</p>
<p><strong>EDIT: jQuery form code</strong></p>
<pre><code>$('.entry__form').submit(function(ev) {
    ev.preventDefault();
    var entryData = $(this).serialize();
    ...

    $.post({
        url: '/',
        dataType: 'json',
        data: entryData,
        success: function(response) {
            if (response.success) {
                console.log(&quot;Entry success&quot;);
            }
        }
    });
});
</code></pre>
<p>This <strong>does</strong> console out &quot;Entry success&quot; and adds the entry to the database.</p>

CC BY-SA 4.0
2020-07-14T09:33:51.243Z
Can you add the code for the form?
Oli
CC BY-SA 4.0
2020-07-14T13:32:21.247Z
@Oli Done, it's a simple (and successful) Ajax call.
brunouno
CC BY-SA 4.0
2020-07-14T14:02:28.447Z
Do you set `enabled` on the entry you are saving?
Oli
CC BY-SA 4.0
2020-07-14T14:20:52.997Z
Yup. Everything works after a couple of browser refreshes which is what I find odd.
brunouno
CC BY-SA 4.0
2020-07-14T14:23:52.567Z
And are you posting to Craft's `entries/save-entry` or a custom controller action?
Oli
CC BY-SA 4.0
2020-07-15T15:35:43.650Z
Are you using MAMP or some other system? Is opcode caching on?
RitterKnight
CC BY-SA 4.0
2020-07-17T20:07:43.570Z
It's a live LEMP system.
brunouno
<cache><craft-pro>
How to stop caching entries/templates?
# How to stop caching entries/templates?

(Asked by: username_0 on 2020-07-13)

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 or 3 times. This is the code I use to fetch them:
Craft entries loop
{% extends "layout" %}

{% block content %}

    {% set entries = craft.entries.section('cotizaciones').authorId(currentUser.id).orderBy('dateCreated desc').search('statusDeCotizacion:recibido OR statusDeCotizacion:enProceso').limit(null) %}
    {% set countEntries = craft.entries.section('cotizaciones').authorId(currentUser.id).orderBy('dateCreated desc').search('statusDeCotizacion:recibido OR statusDeCotizacion:enProceso').count() %}

    {% if countEntries > 0 %}
        {% for entry in entries %}
            {% include "..." with {'active': true} %}
        {% endfor %}
    {% else %}
        NO ENTRIES
    {% endif %}

{% endblock%}

I've run some tests on Incognito and it seems to work a lot better, is there a default cache that I can bypass to make this process more seamless?
EDIT: jQuery form code
$('.entry__form').submit(function(ev) {
    ev.preventDefault();
    var entryData = $(this).serialize();
    ...

    $.post({
        url: '/',
        dataType: 'json',
        data: entryData,
        success: function(response) {
            if (response.success) {
                console.log("Entry success");
            }
        }
    });
});

This does console out "Entry success" and adds the entry to the database.

**Tags:** cache, craft-pro
> **Comments:**
> **username_1**: Can you add the code for the form?  
> **username_0**: @Oli Done, it's a simple (and successful) Ajax call.  
> **username_1**: Do you set `enabled` on the entry you are saving?  
> **username_0**: Yup. Everything works after a couple of browser refreshes which is what I find odd.  
> **username_1**: And are you posting to Craft's `entries/save-entry` or a custom controller action?  
> **username_2**: Are you using MAMP or some other system? Is opcode caching on?  
> **username_0**: It's a live LEMP system.  

---

## 0 answers

