Cache prevents forms from operating properly

More
19 Oct 2016 11:44 - 19 Oct 2016 14:58 #1 by Demis [Fox-Labs]
Demis [Fox-Labs] created the topic: Cache prevents forms from operating properly
When the form does not shows any Thank you message

Under some circumstances, after the form submission, it happens that the notifications are sent, but instead of displaying a thank you message, or any warning due to invalid values, it simply returns blank as it was at the beginning.

When this occurs, it is a clear symptom that a cache memory is giving us an outdated version of the form.


How the cache works

Any cache mechanism is based on the assumption that the output of a module or of a whole a page, does not change during the time.
Under this conditions, Joomla saves a lot of time by pulling out of the hat the final output, instead of running the same PHP code again and again, which would waste time to produce always the same result.

This assumption is no longer true when the page contains a form. You expect different outputs when you see it for the first time, after a failing submission, and after a successful one.
On the contrary, caching a form prevents any interaction with it, and shows always to everyone the same output.
Therefore, in order to make the form work, any cache system must be disabled.
This does not mean to give up to the cache on your entire website. You can still benefit from the cache system, but it must be disabled on the pages containing a form.


Can I enable the plugin "System - Page Cache" in order to cache all the pages of my website without affecting Fox Contact menu items?

Yes, you can.
Fox Contact, when created as a Menu Item, automatically inhibits the "System - Page Cache" plugin limited to its own menu item, without affecting all the other pages on your site. There is nothing to configure or worry about.
What was said, applies to the "System - Page Cache" plugin bundled with Joomla. If you are using a third party cache plugin, Fox Contact doesn't know the correct way to inhibit it.


Can I enable the "Cache" feature under "Joomla Global Configuration" in order to cache all the modules of my website without affecting Fox Contact modules?

Yes, you can.
Fox Contact, when created as a Module, automatically inhibits the "Module Cache" limited to its own module, without affecting the cache mechanism for all the other modules on your site. Once again, there is nothing to configure or worry about.
What was said applies to a Fox Contact module loaded using a standard Joomla module position. If you load the module through a plugin, or a third party extension, any use of the cache feature depends on the plugin or the specific extension which is loading the module.
The "Content - Load Modules" plugin (also said loadposition), which is bundled with Joomla, is an example of module loading through a plugin. In our experience, it doesn't give us problems, but this is not necessarily true for all the third party plugins.


How to diagnose a cache problem

There are several clues that may help you to detect a problem related to a cache system.

Unique timestamp
The easiest way is taking a look to the raw HTML source code of your page.
Search for an HTML comment generated by Fox Contact, and pay attention to the "time" value. In this example, it is "40.48".
<!-- Fox Contact [scope:component] [id:100] [time:40.48] -->
Now reload the page. Under normal conditions, the "time" value is supposed to change every time you visit this page.
If the time value has not changed, then you are seeing and outdated version, hence you have a cache problem.

HTTP headers

Disclaimer: If you don't know what HTTP headers are, and how to inspect them, then this part is not for you.

Looking at the HTTP response header you could find

X-Cache-Status:HIT

The status HIT means that the page has been found in cache and has been served to the browser.

A 304 HTTP return code is another clue of a cache system. The server tells us that the page has not been modified, and the copy stored in the browser can be used.

Status Code:304 Not Modified

In case the HTTP return code is 200, you may notice in the response headers that "Date" and "Last Modified date" are different.
Under normal conditions, the "Date" and "Last-Modified" headers are supposed to show the same value.

Date:Wed, 19 Oct 2016 11:45:00 GMT
Last-Modified:Wed, 19 Oct 2016 11:40:00 GMT


Hot to disable the cache that hurts

Given that limited to Joomla standard cache systems, there is nothing to configure or worry about, in case of cache related problems, the cause must be found in either third party extensions, or server configuration.

Third party extensions
It may be a plugin, but the most of the time it's a template.
For unknown reason, some template creators are not aware about (or not satisfied by) the Joomla standard cache system, so they implements their own cache system.
In these cases the cache can be turned off in the template (or plugin) properties. The most of the time they also provide a way to selectively exclude components or modules from their cache, but our advice is to disable it completely.
The cache system is like an engine for a car. One is useful. Adding more is useless.

Network services / server configuration
Sometimes a "Reverse Proxy with Caching" layer exists between your web server and the user's browser.
In these cases talk with your hosting provider or network administrator.

Please Log in or Create an account to join the conversation.