Tuesday, April 08, 2008

When you're sure your code is correct, but APEX shows something different...

I already blogged once what you can do when you're looking at one of your bugs and you just don't see it.

Today I had it again... a customer was calling me that something was not behaving as expected. So I went into my development system and had a look at it. Worked like a charm on my system. I login to their system and test it and yes they were right: there was a piece visible that shouldn't be there!

The code was identical... Argh!

It happened to me before, but for an odd reason it always takes me a few minutes to remind myself!

Do you know you can Cache your page in APEX? Well, you can (go to your Page Attributes - Cache). I use it to improve performance. The feature is great, until you change something on the page and forgot it's cached ;-)

It would be nice if the APEX engine detected you changed the page in your development environment (sort of page checksum for the whole page) and verifies this. If the checksum is different it should get the new version, but it doesn't.

You can flush your cache manually by using following procedures in the APEX_UTIL/HTMLDB_UTIL package:

procedure purge_regions_by_app (
-- Purges all cached regions for a given application.
p_application in number);

procedure purge_regions_by_name (
-- Purges all cached regions of a given name for a given application
-- and page.
p_application in number,
p_page in number,
p_region_name in varchar2);

procedure purge_regions_by_page (
-- Purges all cached regions for a given application and page.
p_application in number,
p_page in number);

Caching (APEX 3.0) is a really nice feature, but I wouldn't put it on till you end the development...


Jorge said...

Dimitri, good post. When would you use caching? Or maybe a better question, on what type of page?

Dimitri Gielis said...

Hi Jorge,

You can definitely use it for static pages in APEX.
Or pages you know that don't change for a certain amount of time. That's where I use them.

You've different kinds of caching (user/session), on different places (page/region) and you can also specify a condition when to cache.

Hope that helps,

Anonymous said...

Use Ruby on Rails and you wot have tat problem

Dimitri Gielis said...

Hi Anonymous,

If you use Ruby on Rails you'll get a lot more other problems ;-)

And what I had is not a problem, it's a feature...


Onur said...

Hi Dimitri,
I really appreciate your efforts regarding APEX. Thank you very much for this useful blog.
I have this question.
I have to develop my apex app. on my local machine until my company upgrades to 10g. So I use a dblink in order to communicate from my local XE to EBS 9i. But if the page items(LOV, Report etc) including sql's with dblink are not stable. I mean they work now but wont a minute later. I really pisses me off.
Have you experienced a similar problem ? Do you have any suggestions. Thx in advance.

Anonymous said...

Hi Dimitri

Thanks a stack for all the very useful stuff you publish.

I managed to get Highslide working nicely because of this - except that I have a caching issue.

When I load new images into the repository, I sometimes have to refresh the browser window to see them.

Any idea why?


Ariel said...

Mate, I cant even get caching to work on our machine. I've cached numberous pages in our application but if I look in workspace administrator -> manage services -> manage cached pages - the page shows that numerous pages are cached, but "cached pages" column show all zeros! There's no application selectible under purge by application or purge expired. Don't know what's going on.

Stew said...

Thanks for the tip!