Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controlling caching of block #486

Closed
AnthonyLavin opened this issue Apr 3, 2014 · 7 comments
Closed

Controlling caching of block #486

AnthonyLavin opened this issue Apr 3, 2014 · 7 comments
Labels

Comments

@AnthonyLavin
Copy link

Hi, I have a contact-us page with a block containing the contact-us form. I want just this block to not be cached. Here is my contacts.xml:

<contacts_index_index translate="label">
    <label>Contact Us Form</label>
    <reference name="head">
        <action method="setTitle" translate="title" module="contacts"><title>Contact Us</title></action>
    </reference>
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
        <action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
    </reference>
    <reference name="content">
        <block type="core/template" name="contactForm" template="contacts/form.phtml">
            <action method="setEsiOptions">
                <params>
                    <access>public</access>
                    <scope>page</scope>
                    <ttl>0</ttl>
                </params>
            </action>
        </block>
    </reference>
</contacts_index_index>

I have tried every combination of settings in the EsiOptions I could find but I cannot get the block to stop caching. For testing purposes I have added a timer to my contact form template and no matter what I try it gets cached.

I have managed to stop caching a block that is in the default handle but I'm having no luck with this form.

Thank you
Anthony

@eth8505
Copy link
Contributor

eth8505 commented Apr 3, 2014

Are you sure it's the block being cached and not the entire page?

@AnthonyLavin
Copy link
Author

How do I tell if the page is being cached and not just the block? Other parts of the page such as in the header respect my turpentine configuration options, like the cart and log in / out links that are set to private.

@eth8505
Copy link
Contributor

eth8505 commented Apr 3, 2014

You could inspect the response headers of the document and check what value the Age header has. This will only work if you have debug headers active or your own IP defined in the magento debug IPs.

@AnthonyLavin
Copy link
Author

I flushed the cache and then checked the age value, it is continually increasing so it looks like the page is being cached. Is there a way to un-cache the page? Would I then have to set caching options for all the blocks on the page individually?

@eth8505
Copy link
Contributor

eth8505 commented Apr 4, 2014

You could not cache the whole page by specifying

<contacts_index_index translate="label">
<turpentine_cache_flag value="0"/>
</contacts_index_index translate>

And from what I gather from the esi policy docs https://github.com/nexcess/magento-turpentine/wiki/ESI_Cache_Policy you could do the following to hole-punch just the block:

<contacts_index_index translate="label">
<reference name="contactForm">
                <params>
                    <access>private</access>
                    <method>esi</method>
                    <ttl>0</ttl>
                </params>
</reference>
</contacts_index_index>

The above could work, but I haven't tried that myself.

@aheadley
Copy link
Contributor

aheadley commented Apr 4, 2014

What @eth8505 suggested for not caching the contacts page, or for hole-punching should work.

@sprankhub
Copy link
Contributor

Mind that wholepunching the contactForm block ist not enough. The form action is only post in this case and not the whole shop URL plus contacts/index/post. Hence, you need to exclude the whole contacts page.

miguelbalparda added a commit that referenced this issue Feb 26, 2018
added ESI options for contact form, #116, #486
meminuygur pushed a commit to magefly/magento-turpentine that referenced this issue Jun 5, 2018
meminuygur pushed a commit to magefly/magento-turpentine that referenced this issue Jun 5, 2018
meminuygur pushed a commit to magefly/magento-turpentine that referenced this issue Jun 5, 2018
meminuygur pushed a commit to magefly/magento-turpentine that referenced this issue Jun 5, 2018
meminuygur pushed a commit to magefly/magento-turpentine that referenced this issue Jun 5, 2018
meminuygur pushed a commit to magefly/magento-turpentine that referenced this issue Jun 5, 2018
meminuygur pushed a commit to magefly/magento-turpentine that referenced this issue Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants