Observer

Τελευταία ενημέρωση από Elxis Team

Elxis document observation system and cache

Elxis Document has a special observation system that marks the data imported into the site's HEAD section such as stylesheets, javascript files, page title, META data, etc, in a time period. This period begins after calling the beginObserver method and ends when we call the endObserver method of the elxisDocument library.

The observed items can be fetched by using:

eFactory::getDocument()->getObserved();

The returned result is an array of arrays with keys type and contents.


Observer and cache

The observer is directly related to Elxis Cache. How? Well, the observer is a solution Elxis Team gave to a very annoying issue when we cache items. Very often these items needs to put things into the document head section such as stylesheets, css, javascript, etc. If we cache the HTML output of our script and in the next click display it from cache then the cached item will miss its head data (css, js, etc) and the result will be a disaster. The item wont have its custom style or javascript in the head.

When the elxisCache state is 2 (the system is ready to generate/refresh cache) the Observer marks all the data our script puts into the document's head section. When it actually stores the output into the cache it also stores these marked data. So, when our cached file is loaded elxisCache will also put these data back into the document's head!

The best of all is that you have nothing special to do! elxisCache and elxisDocument do all the work automatically (the observation, the save and the restoration). The Observer will restore: CSS files, CSS code blocks, Javascript files, Javascript code, Javascript libraries, Document Ready calls, Link tags, Custom tags and code put in head, page title, page meta description and page meta keywords.


Έχει διαβαστεί 4366 φορές
Σελίδες εξόδου
Προηγούμενο άρθρο
Σελίδες εξόδου
Icon packages
Επόμενο άρθρο
Icon packages

Μπορείτε να αντιγράψετε, διανείμετε και παρουσιάσετε τα άρθρα αυτού του ιστότοπου για μη εμπορικούς σκοπούς.
Creative Commons 3.0