Difference between revisions of "Cache Demo 1"

From FollowTheScore
Jump to: navigation, search
Line 1: Line 1:
 
This page demonstrates the use of MediaWiki´s static file caching.
 
This page demonstrates the use of MediaWiki´s static file caching.
  
== Setup ==
+
''Please watch changes in the content of the next chapter!''
 +
 
 +
== Included content (from page [[Cache Demo 2]] ==
 +
{{#dpl:title=Cache Demo 2|include=*|allowcachedresults=true}}
 +
 
 +
__TOC__
 +
 
 +
== Demonstration ==
 
The following links allow you to switch between three different ways to access the current page:
 
The following links allow you to switch between three different ways to access the current page:
 
{{#vardefine:thispage|Cache_Demo_1}}
 
{{#vardefine:thispage|Cache_Demo_1}}
Line 20: Line 27:
 
|}
 
|}
  
First you should click on the third link and then on the first one. Now you are seeing the normal (cached) version of the current page. The cache is up to date, so there is no difference from the other versions. In the next chapter we are going to include the content of another page named [[Cache Demo 2]]. This is the interesting part of the game. We will watch how (if) the piece of included text changes when we make changes to the underlying page. We execute <code><nowiki>{{#dpl:title=Cache Demo 2|include=*|allowcachedresults=true}}</nowiki></code>:
+
First you should click on the third link and then on the first one. Now you are seeing the normal (cached) version of the current page. The cache is up to date, so there is no difference from the other versions. In the first chapter of the current document we have included the content of another page named [[Cache Demo 2]]. This is the interesting part of the game. We will watch how (if) the piece of included text changes when we make changes to the underlying page.  
  
 +
The statement we used to include is:
 +
<code><nowiki>{{#dpl:title=Cache Demo 2|include=*|allowcachedresults=true}}</nowiki></code>
  
== Included contents (result of a parser function call) ==
 
{{#dpl:title=Cache Demo 2|include=*|allowcachedresults=true}}
 
  
== Watch the effect ==
+
== Make changes and watch the effect ==
 
# Now open [[Cache Demo 2]] in a separate browser tab and modify the content of that page.
 
# Now open [[Cache Demo 2]] in a separate browser tab and modify the content of that page.
 
# After saving the page switch back to the current page and reload its content, either by pressing your browser´s reload button or by clicking on the ''first'' of the three above links.
 
# After saving the page switch back to the current page and reload its content, either by pressing your browser´s reload button or by clicking on the ''first'' of the three above links.

Revision as of 09:39, 27 February 2009

This page demonstrates the use of MediaWiki´s static file caching.

Please watch changes in the content of the next chapter!

Included content (from page Cache Demo 2

==================================================================
This is page Cache Demo 2.
Change the following letter code to test the caching:     CODE-145
==================================================================

Demonstration

The following links allow you to switch between three different ways to access the current page: {{#vardefine:thispage|Cache_Demo_1}}

1 cached version (standard)

[[{{#var:thispage}}|cached version]] (standard)

[http://semeb.com/dpldemo/index.php?title=Cache_Demo_1]

[[Cache Demo 1]]

2 [[Special:Call/:{{#var:thispage}}|updated version]] (leaving the cache unchanged) [[Special:Call/:Cache Demo 1]]
3 updated version (with cache update) [http://semeb.com/dpldemo/index.php?title={{#urlencode:{{PAGENAME}}}}&action=purge]

First you should click on the third link and then on the first one. Now you are seeing the normal (cached) version of the current page. The cache is up to date, so there is no difference from the other versions. In the first chapter of the current document we have included the content of another page named Cache Demo 2. This is the interesting part of the game. We will watch how (if) the piece of included text changes when we make changes to the underlying page.

The statement we used to include is:

{{#dpl:title=Cache Demo 2|include=*|allowcachedresults=true}}


Make changes and watch the effect

  1. Now open Cache Demo 2 in a separate browser tab and modify the content of that page.
  2. After saving the page switch back to the current page and reload its content, either by pressing your browser´s reload button or by clicking on the first of the three above links.
  3. When you do this for the first time after you changed Cache Demo 1, you will note that you get the updated content. Why this happens is still somewhat unclear. In that case just make another update to Cache Demo 2.
  4. Now you will see that the changes of Cache Demo 2 are not reflected in Cache Demo 1.
  5. Now press the second button of the above link list to show the updated page. You will see the most recent content of Cache Demo 2 appear in the respective chapter of Cache Demo 1.
  6. Switching back to the first button will still show the old cached version of the page. This is also what a third person would see who is not logged in to the wiki.
  7. After pressing the third button of the list you will see the most recent content AND the cache will be updated. So afterward a click on any of the three above buttons will deliver the same result. An anonymous user pressing the third link will be confronted with a question whether he wants to erase the cache or not. Answer with 'yes'!

Now you can repeat the whole game of editing Cache Demo 2 and watching the effect on Cache Demo 1 until you get the idea. You may also want to show Cache Demo 1 on a second computer with an anonymous user to study the cached view from this perspective.

Try yourself

What is it good for?

If you have a huge wiki with significant traffic you may be afraid that complex parser function calls (like some calls of DPL) will slow down your wiki. In this case you can enable page caching. Then most users will get the version from the cache while you or some privileged users still can access the most recent version.

To activate page caching in your wiki you must

  • create a directory $WIKIHOME/cache on your server
  • add the following lines to LocalSettings.php:
    $wgFileCacheDirectory = "$IP/cache"; 
    $wgShowIPinHeader     = false;  
    $wgUseFileCache       = true;

See also the MediaWiki manual pages.

Example with a typical DPL query

Note that DPL normally disables caching to ensure that it always delivers results based on the latest version of all pages.

Therefore DPL must explicitly be told to allow cached results /(using allowcachedresults=true). Using this option without enabling MW page caching does not help very much as DPL still would have to execute SQL statements and process the result. The real performance boost comes when DPL doesn´t have to work at all ...

In the following example we generate a list of all pages starting with "A". We put the time of the generation into the headline so that we can see how the cache works.

generated at Saturday, 16:12 -- 90 pages found. A1  -  Abc/def  -  A ECP-00055 test page  -  Article with underscore  -  Activity Page 1  -  Activity Page 2  -  A2  -  Aa  -  Annotation URI  -  An article which is only referenced by a DPL query  -  AbC  -  Article connected by DPL category keyword  -  Abc  -  Activity 1  -  Activity 2  -  Activity 3  -  A  -  Apache服务器架设的简单,由小P发布  -  Application DPL-tracker  -  Applying a template to all pages of a given category  -  Allowing true caching by DPL dev page  -  Amethyst  -  Allowing true caching by DPL dev page  -  AssaCom  -  Alf63/C1  -  Alf63/C2  -  Alf63/RP.dpl.default  -  Alf63/SeqSize  -  Alf63/RP  -  Alf63/SeqGet  -  Alf63/RP of  -  Adomjan  -  Arcandio  -  Armin.Egner  -  Alf63/Seq test1  -  Aaron Overton  -  Awodejko  -  Alf63  -  AJim  -  Alf63/P1  -  Anonguy9  -  Arturro  -  Anonguy9  -  Alf63/P1  -  Arrow-closed.png  -  Arrow-open.png  -  Asking a calendar kit 2.png  -  Asking a calendar kit 1.png  -  Amp  -  Ask is a  -  Abc/x123  -  Articles  -  Alias Wgraph  -  African Country  -  Audio  -  ActivitySummary  -  Activity Description  -  About  -  AT&  -  Apachetest  -  AT&T  -  African Union member states  -  Antwerpen  -  Another Topic  -  Allows value  -  Age  -  Annotation URI  -  Architecture  -  Ahnen  -  Add new option to exclude page sections  -  Allow vertical alignment of node labels  -  Assigning absolute position of 0-0  -  Ampersand fails in category names  -  Allow includereplace or ability to ignore included section headers  -  Addlasteditor crashes new article  -  AddContribution missing prefix  -  AddContribution missing prefix regression  -  An Error of conbime using of StringFunctions extension and Simple Form  -  Adduser  -  Add "minimum-number-of-revisions" like Criteria for page selection  -  Article Titles/content added as sub bullets  -  Asking a parser "replace " demo  -  Article count is wrong  -  Add a template in the pages automatically by DPL  -  AiSee crash due to several near edges  -  Allow multiple surrogate templates, add/change syntax  -  Articlecategory doesn't work in 1.6.8  -  A problem in the conbination DPL 1.7.4 and MW1.3 using Chinense interface  -  Arbitrary adding of empty paragraph  -  Asking a calendar kit  -  


Example 2 - offering a refresh link

If you use allowcachedresults=yes+warn DPL will include a template named Template:DPL Cache Warning into the resultsheader. This is a convenient way to use caching and add a refresh link to the result.

90 pages. A1  -  Abc/def  -  A ECP-00055 test page  -  Article with underscore  -  Activity Page 1  -  Activity Page 2  -  A2  -  Aa  -  Annotation URI  -  An article which is only referenced by a DPL query  -  AbC  -  Article connected by DPL category keyword  -  Abc  -  Activity 1  -  Activity 2  -  Activity 3  -  A  -  Apache服务器架设的简单,由小P发布  -  Application DPL-tracker  -  Applying a template to all pages of a given category  -  Allowing true caching by DPL dev page  -  Amethyst  -  Allowing true caching by DPL dev page  -  AssaCom  -  Alf63/C1  -  Alf63/C2  -  Alf63/RP.dpl.default  -  Alf63/SeqSize  -  Alf63/RP  -  Alf63/SeqGet  -  Alf63/RP of  -  Adomjan  -  Arcandio  -  Armin.Egner  -  Alf63/Seq test1  -  Aaron Overton  -  Awodejko  -  Alf63  -  AJim  -  Alf63/P1  -  Anonguy9  -  Arturro  -  Anonguy9  -  Alf63/P1  -  Arrow-closed.png  -  Arrow-open.png  -  Asking a calendar kit 2.png  -  Asking a calendar kit 1.png  -  Amp  -  Ask is a  -  Abc/x123  -  Articles  -  Alias Wgraph  -  African Country  -  Audio  -  ActivitySummary  -  Activity Description  -  About  -  AT&  -  Apachetest  -  AT&T  -  African Union member states  -  Antwerpen  -  Another Topic  -  Allows value  -  Age  -  Annotation URI  -  Architecture  -  Ahnen  -  Add new option to exclude page sections  -  Allow vertical alignment of node labels  -  Assigning absolute position of 0-0  -  Ampersand fails in category names  -  Allow includereplace or ability to ignore included section headers  -  Addlasteditor crashes new article  -  AddContribution missing prefix  -  AddContribution missing prefix regression  -  An Error of conbime using of StringFunctions extension and Simple Form  -  Adduser  -  Add "minimum-number-of-revisions" like Criteria for page selection  -  Article Titles/content added as sub bullets  -  Asking a parser "replace " demo  -  Article count is wrong  -  Add a template in the pages automatically by DPL  -  AiSee crash due to several near edges  -  Allow multiple surrogate templates, add/change syntax  -  Articlecategory doesn't work in 1.6.8  -  A problem in the conbination DPL 1.7.4 and MW1.3 using Chinense interface  -  Arbitrary adding of empty paragraph  -  Asking a calendar kit  -