We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Should I use Smarty caching or cache-control headers in .htaccess?

utzi
utzi asked
on
Medium Priority
720 Views
Last Modified: 2012-05-06
Hello experts,

I'm using software written in PHP that uses the smarty templating system. I have set up image caching for the site using cache-control headers, but now I want to cache the html output also. On some pages I want to cache nothing, and on others I want to cache everything, and on others I would like to be able to selectively cache some parts (the output of other subtemplates, which are separate .tpl files).

My question is, should I even bother with smarty? If I do it with cache-control, I won't be able to cache only parts of pages I guess, but I can live with that. Is there a compelling reason to use smarty instead, or use both together?

Thanks for any insight you can provide.

Utzi
Comment
Watch Question

Commented:
Here Smarty and Cache Control do  completely different things.

Smarty caches the rendered output of defined areas of your templates. That's for a cross-client fonctionnality. One client comes, hits and cache a page. The second will hit the page and get directly the cached content, thus limiting the load on your server.

Cache-control works for only one client. It is a browser-side caching. It means if you get 100 000 different users looking your frontpage, for all of them the server will compute its content.

My best advice... if your site is used by a very little amount of people, often refreshing, then cache-control can be good. Any other case will give a 100 times better result with Smarty caching.
The 2 are entirely compatible though!

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Hi,

Thank you for your comments. I understand the difference and turned on smarty caching to test it out. Everything looked good, until I found that the caching broke parts of my admin area (which is run by smarty too). I will try implementing smarty caching on appropriate pages (that receive the most traffic), but not as a blanket solution, because of this.

Thank you very much!

Utzi
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.