caching snippets (modX) -


i simple cruising through modx options , noticed option cache snippets. wondering kind of effect have (downsides) site. know caching improve loading time of site keeping them 'cached' after first time , reloading updates seems true. question simple: there downsides caching snippets? cheers, marco.

great question!

the first rule of modx (almost) cache. they've said in own blog.

as said, loading time lower. let's basics on floor first. when chose cache page, page output stored file in cache-folder. if have small , simple site, might not see biggest difference in caching , not, if have complex 1 lots of chunks-in-chunks, snippets parsing chunks etc, difference enormous. of websites i've made goes down 15-30 levels parse content in come sections. loading fresh database can take coupe of seconds, while loading flat-file take few microseconds. there huge difference (remember that).

now. can cache both snippets , chunks. important remember. can cache 1 chunk while uncache next level. using modx's brilliant markup, can chose cache , uncache, in general want as possible cached.

you ask downside. there none, but there few cases can't use cached snippets/chunks. mentioned earlier, cached response divided each page. means if have page (or url or whatever want call it), display different content based on example get-parameters. can't cache search-result (because content changes) or page pagination (?page=1, ?page=2 etc produce different output on same page). case when snippet's output random/different every time. put random quotes in header, needs uncached, or see first random result every time. in other cases, use caching.

also remember every time save change in manager, cache wiped. means if example display latest news-articles on frontpage, can still cached because not display different content until add/edit resource, , cache cleared.

to sum up. caching great , should use as possible. make snippets/chunks cached, , if crash problems, first thing check.

using caching makes webserver respond quicker (good user) , produces fewer queries database (good you). in all. caching gift. use it.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -