CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Cache Clienti18n.php

Print topic Send  topic

Author Message
melvyn


Posts: 333
Posted: 06/08/2009, 9:32 AM

I've coded a site very minimalistic. I've avoided the numerous request and try to only get the thing I need.

I'm having troubles with ClientI18N.php?file=Functions.js&locale=en because always is being downloaded. I'm upset with it.

I would like to download once, use at least for the rest of the session. I don't want to download each time a form/grid is shown.

Is there some known way to reach this?

Thanks
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 7:10 AM

Hi

If you take a look at what Clienti18.php is you will realize that it is not downloaded at all.

It is a php script that runs on the server and is used to configure javascript files on the fly.

The line you cited is to be able to use functions.js configured for a particular locale for date display and language stuff.

I suppose with carefull rework of Functions.js javascript you could relpace the use of Clienti18.php to just load the Functions.js file.

Also, just looking at it briefely, IF you do not use interantionalization and no custom client side code, you might be able to get rid of the Clienti18.php line all together. (Can't be sure about that)


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 7:33 AM

I Just ran a test and did discover if you add a record or a grid to a page the clienti18.php line gets added.

That is becasue the buttons and page loading is using functions in the Functions.js file.

So. the only option seems to be to re-work Functions.js and include that.

But it also seems you might be able to just copy the function addEventHandler() from the Functions.js file into your simple pages then remove the line for clienti18.php

Of course do not use internationalization or add any other client side events

This should work for you.

Let me know

John

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 7:55 AM

I just discovered something else.

Make the changes after all your records and buttons had been added to your page.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
melvyn


Posts: 333
Posted: 06/12/2009, 8:00 AM

I don't use CCS' client side events, instead I add events by hand. Unfortunately I use internationalization, so it must be downloaded.
Anyways, when I return to a page I've visited the only thing to redownload is page.php because it's components are just in the browser cache. CCS works it fines in almost everything but download the Clienti18n file again. I also noticed that each include pages includes it's own link to clienti18n file so I remove it manually from the generated html becase I don't need a second call from the header, a third call from the footer and N-th call from include pages.
This is how firebug reports a page for first time:

Notice 129kb from cache. Those 129kb comes from the visit to another page in the site which contains all those shared elements (background images, js scripts and styles).

Now revisiting the same page:


Notice that propiedades.php is called (which is correct) and Clienti18n.js again (which must not).

Now see from YSlow the comparission:


1 html (propiedades.php)
1 javascript (clienti18n.js)

Also note it appear 7kb (6.4) instead of 28kb, that's because I gzip it's php generator (ClientI18N.php) with a ob_start("ob_gzhandler"); in the header.
This behavior happen same without compression.

I added compression looking for better response time, because each page is called from javascripts requests and we're looking for the fastest way to load everything. That's the reason we would like to save theese 7kb. Another reason is from localhost call to each file take less than 100ms but Clienti18n.js take 640ms.

It can look like something without importance. I guess I'm suffering from Obsesive-Compulsive disorder...
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 8:20 AM

LOL

I get that way too.

Maybe what you can do is modify clienti18.php to write a temp .js file at the server at some initialization point. Have the script include line load that js file directly. That should cause it to cache locally.

Control of this maybe by a session variable. You would of course need to manage the deletion of these temp files somehow.

Or create a Function.js file for each locale you are using in your internationalization and drop the proper js fiole name at run time.

You could even fake client118.php to create thes for you initially instead or reworking it yourself.

Just change the echo $file_content to write the content to a file for each locale you app is using. Then re-name them to Functionen.js or Functiones.js

Then replace the clienti18.php script tag to

<script type="text/javascript" lang="javascript" src="{func}"></script>

Then in your before show event do :

global $Tpl;

if $locale="en" $Functions="Functionen.js";
if $locale="es" $Functions="Functiones.js";

$Tpl->setvar("func",$Functions);

This way I think your HTML would have a script tag that loads an absolute .js file and will be cached by your browser.

LOL

How is this for Obsessive-Compuslive...

John


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 8:26 AM

BTW. Let me know if you try it and if it works...

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 8:33 AM

Heck

The more I think about this you could even modify clienti18.php to do this dynamically for you and preserve the extensibility for CCS internationalization automatically.

Oh No!!! I'm being obsessive compulsive again. Just a thought lol




_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
melvyn


Posts: 333
Posted: 06/12/2009, 8:44 AM

I'm going to try htaccess to rewrite src="ClientI18N.php?file=Functions.js&locale=en" into src="ClientI18N.js" so the browser request an aparent static js file. Then I'll rewrite with .htaccess to custom_clienti18n.php which will have this line:
include("ClientI18N.php?file=Functions.js&locale=" . $_SESSION['locale'] );

I hope this can return the right file if the user change the language. This can't be tested in my local development so I'm going to wait to test in the server.




_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 8:54 AM

Think about it Melvyn

That won't work I do not think.

Putting JS into a PHP script will do nothnig for you unless you write that to the HTML Template.. Remember what the output of clienti18.php is? It's output is javascript. Your include will just echo javascript in the middle of your php code. If you want to do it this way you will need ob_start then get the output of your include into a string. The you will need to use the $Tpl object to write thet into some script tags.

Also the 640ms to run the php script will still exist if you run it every time.

Seriously. Just create the individual locale .js files and use the one you need at run time.

But. There is always more than one way to skin a cat.

Let me know what works.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 8:55 AM

Incidentally, The way I initially described it, would run on your local server


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 8:59 AM

I also think, if you look at clienti18.php no matter how you run it, it seems it always creates a header. What do you bet it is the header that is telling the browser the file has changed and causes a re-load every time.

Just another thought.

But. LEt me know if your idea works. I would be curious about all this

Thanks

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
melvyn


Posts: 333
Posted: 06/12/2009, 9:29 AM

I've failed at large.
The first step must be to ask myself theese two question:
1) What the hell is functions.js and ClientI18N.php for?
2) What happen if I just delete the reference to them?

As far as I know Clienti18N is for translations and functions.js is for local client-side events.
Since I just don't use any custom client side events generated by CCS and just use my own hand coded in the site's .js script functions.js become useless. By the other way generated html comes translated to the browser, so where do I need functions.js?

So I just deleted the entire line:
<script language="JavaScript" src="../ClientI18N.php?file=Functions.js&locale={res:CCS_LocaleID}" type="text/javascript" charset="utf-8"></script>

And almost everything appear to be working well in english and spanish; the buttoms appear well in the desired language. Datepicker don't work, and maybe another things can get out. I don't use date picker too much.

Then I read the functions.js file in order to get knowledge about it contents. I'll save the generated functions.js for each language save them as functions_es.js and function_en.js and then include in the page as:
<script language="JavaScript" src="functions_{res:CCS_LocaleID}.js type="text/javascript" charset="utf-8"></script>

So I get the correct locale in each load and get them cached. Include only if needed. That's a light variation of your recomendation above.

I noticed that sometimes CCS regenerates and add the line again and again and again... Just discovered one page which included it 5 times in the same html bunch, plus one in the header, another in footer and another 2 in two include pages, just 9 references to clienti18n.

Something more: maybe doesn't get cached because the parameters in it's filename. Wihout parameters cache doesn't matter.
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 9:39 AM

Yeah

Now you see what I am talking about.

Your way of adding the proper Functions.js file is much nicer than mine. No before show event needed. That's elegant.

You do need Functions.js for things that CCS generates like confirm dialog on delete and some other things. So I think it best to keep it in there as you have it. You will notice once you see the Functions_xx.js created by clienti18.php. It takes no parameters after clienti18.php generates it.

Also when you look into clienti18.php you will see where it just echos the file content. If you change that code to a write to a file you will have your localized Functions.js.

The same technique could be used on datepicker also aso it will cache as well if you need it.

Also, as I started to get into but it probably is more work than it's worth. Clienti18.php could be modified to be an include in the php code. Create the locale specific file if not found. if found just exit.

Then apply your script tag as you described. Then all files would be static js files for all locales dynamically.

Just a thought.

LEt me know how it works


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 9:41 AM

BTW. I do not know why CCS generates more than one entry for clienti18.php.

Only one is needed as you know.

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/12/2009, 10:03 AM

BTW

If you use FCKEditor and maybe Ajax you will need Functions.js.

Soooo.... Use the script tag method you suggested. and just dummy Clienti18.php to create the local specific Functions_xx.js file for each language you use and I think you will have what you are looking for.

John
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/14/2009, 8:07 PM

Hey Melvyn

Just wondering if you got this to work???

John

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.