TransWikia.com

How to stop caching entries/templates?

Craft CMS Asked by brunouno on September 4, 2021

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.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP