Is it too much when some of my pages need almost 110 mysql requests to load from cache (170 when load from database)?
Problem is that I am building portal for local news and it contains a lot of subcategories (Ditto, ditto, ditto...) and also a lot of banners which need to be randomly changed for every page. I know that Ditto can be cached but I need some fields to be always updated (’how long is it since the article was published’). And random banners cannot be normaly cached for obvious reasons.
How many requests is considered to be ’normal’?
-- sorry for my english, bad teacher

Hmm, I created simple log for storing mysql requests to check what is going on inside. For example I don’t understand why snippets are loaded from database everytime they are used. Only phx:phpthumb consumes 20 queries itself! Is it normal? Did I forget to change some settings?
-- sorry for my english, bad teacher

SELECT snippet FROM `xsvoboda`.`x_site_snippets` WHERE `xsvoboda`.`x_site_snippets`.name='phx:phpthumb';
SELECT snippet FROM `xsvoboda`.`x_site_snippets` WHERE `xsvoboda`.`x_site_snippets`.name='phx:cs_limit';
SELECT snippet FROM `xsvoboda`.`x_site_snippets` WHERE `xsvoboda`.`x_site_snippets`.name='phx:phpthumb';
SELECT snippet FROM `xsvoboda`.`x_site_snippets` WHERE `xsvoboda`.`x_site_snippets`.name='phx:cs_limit';
SELECT snippet FROM `xsvoboda`.`x_site_snippets` WHERE `xsvoboda`.`x_site_snippets`.name='phx:phpthumb';
SELECT snippet FROM `xsvoboda`.`x_site_snippets` WHERE `xsvoboda`.`x_site_snippets`.name='phx:cs_limit';
It’s quite obvious that these snippets are being fetched again and again. I don’t know why cache doesn’t work in this case when caching docments is ok. I use include in both of these snippets. Does that matter?
My modx version is 1.0.3, it’s quite recent.
Thank you for quick reply:)
-- sorry for my english, bad teacher

-
☆ A M B ☆
- 24,524 Posts
That’s all coming from PHx. It doesn’t get its snippets from the cache file or from the existing MODx array of snippet code ($modx->snippetCache).
It is weird that phx doesn’t use cache. However it is no longer a problem. I found a way how to keep the functionality and make Ditto cacheable. This reduced the number of requests to 13. 8 of it are my banners so the optimalization is now only up to my code
-- sorry for my english, bad teacher

Quote from: tobice at Jun 11, 2010, 04:13 AMI found a way how to keep the functionality and make Ditto cacheable.
can you explain how do you did optimize your page please ?
CTRL+SHIFT+U - Clear Cache
CTRL+SHIFT+H - Hiding Heft Panel
CTRL+SHIFT+N - Fast Create Resource
CTRL+ALT+P - Preview Recource (in edit resorce window)
CTRL+ALT+S - Save
Quote from: manu at Jun 11, 2010, 06:54 AM
Quote from: tobice at Jun 11, 2010, 04:13 AMI found a way how to keep the functionality and make Ditto cacheable.
can you explain how do you did optimize your page please ?
Actually, it wasn’t big deal after all
My problem was that I wanted to display publish time not like a classical date but like the time which passed since the article was published (for example 3 minutes ago, 5 hours ago, two weeks ago etc). Logically it depends on current time and therefore this value must be counted every time when the page is opened. I wrote small snippet which worked great however I thought it wouldn’t work with Ditto cached. But then I read something about how the caching of snippets works and found out that it is not a problem. So I made Ditto cacheable ([! -> [[) and my snippet inside uncacheable and everything seems to be working fine.
Each Ditto call costs around ten sql requests (including those weird phx queries) and I use Ditto quite a lot. So finally I reduced the number of sql queries from 130 to 13. According to the time of processing, the page is now ten times faster
-- sorry for my english, bad teacher
