Jump to content

custom fields and caching


Doc
 Share

Recommended Posts

Hi,

I'm building my homepage, it contains ~60 custom fields (lines or words I define & translate in the admin in different languages).

The homepage is dynamic and my users are logged.

I'm trying to avoid many MySQL queries to retrieve the fields I've setup in the admin, I think I can do better than 60 different queries to display that content on the home.

Regarding performance, will markup cache a good approach here ?

I understand it makes sense when you have a scrolldown menu which is built within a loop for example but is it still good if I cache 60x a word or a group of words in my code ?

Another idea I had was to dynamically determine which language is used by the user and load a language file which contains the translated text (uk.inc.php) and so on... (less elegant I think, but I'll use that anyway for dynamic expressions such as "you have %nb items in your cart").

Thanks

Link to comment
Share on other sites

Sure @LostKobrakai, let me reformulate :

On my homepage, I have about 60 custom fields, which have been built to store some sentences or words I have to translate.

I suppose that PW will have to make 60 queries in the MySQL DB to retrieve those fields. Perhaps I'm wrong here and PW will ask run only one query with 60 columns... I didn't check on the log.

Although I don't have any performance issue (it's only running on my laptop yet), I was wondering myself, from a theorical point of view / best practice, if I'd better go with markup cache for example to avoid too many queries due to the translation part of the homepage.

My fear is that all my custom fields : $page->home_field1, $page->home_field2, ... match the same corresponding number of queries in the db (60x).

And it that case, perhaps I'd better go with specific cached queries for each custom field I use ?

Another approach I was speaking about : detect the language used and load the corresponding text file (uk.inc.php, it.inc.php, ...).

Is it more clear now ? Or perhaps I'm digging too much and I would better go as is, and see later if I encounter performance problem ?

Thanks

 

 

Link to comment
Share on other sites

May I ask, why you're not using processwire's buildin translation capabilities? 

Regarding the mysql queries. You're correct that you'd get 60 mysql queries, but that's really nothing to worry about if you're not experiencing performance issues. If you would there are various ways to improve uppon that like autojoining fields or one of the many caching solutions of processwire.

Link to comment
Share on other sites

I'm using the PW builtin translation capabilities :)

I'm a beginner with PW but here I'm speaking about my translated fields, the ones I've setup in the admin section.

I've installed the core plugin dedicated to translation, and I can switch easily between fr/uk for example just by modifying the url, and that works great !

I'm a MySQL DBA actually and was thinking : what will going on if I have 50 concurrent users here -> 3000 concurrent queries ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...