views:

191

answers:

2

I'm using a Smarty template for my web application Registration / Sign-up form.

The form is slow to load, can I cache the registration form in order to speed up the loading of the page?

On the form page, I use SESSION and do lots of PHP error checking to ensure that the form fields are completely & correctly inputted. If not, I redisplay the form page with all inputted data and indicate to the user where they have not filled out form field data correctly. My concern, is that this error checking and using $_SESSION will not allow me to cache the page.

A: 

Sure, you can cache the form just like any other template.

Zed
I have lots of error checking on the page to ensure all form fields are completed ... as well as use the $_SESSION variable. Wouldn't that cause me to not be able to cache the page?
A: 

If you've used smarty a smarty template to create the form, than you can cache the template output by with the Smarty Cache.

There is probably another culprit causing this page to load slowly if all of the other are quick. Some things to check for:

  • A slow sql query
  • Including a file or script from another server that doesn't respond quickly
  • A slow javascript function
  • HTML with too many errors

You should be able to narrow this down by eliminating everything on the page, but the form.

Here are some other suggestions from other questions:

Dana the Sane
What concerns me is that I do lots of PHP error validation to ensure that all form fields are inputted correctly and if not, re-display the template page. Wouldn't that cause me to not be able to cache the page?
I don't think that that should cause a problem. I worked on a project where xml soap responses were cached with smarty and the only issue we encountered was with pushing updates to the cache. With your error handling, if the user input is the same, then the same error output from your php will be reported (depending on what is cached). In any case, if you try enabling the cache and repeat a request several times, you'll be able to test this.
Dana the Sane