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

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
utziAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
jcalluCommented:
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!
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
utziAuthor 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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.