適切なRESTキャッシング

ブラックジャックやその他の喜びでハブラハブを書きましょう。 記事ページは3つのボリュームブロックで構成されています。

1.記事の実際のテキスト。 まれにしか変更されません。

2.コメントツリー。 比較的頻繁に変化しますが、時間が経つにつれて変化します。

3.ライブ放送。 小さいが非常に頻繁に変わる。



この記事のあるページが利用可能だとしましょうか?記事:right.cache

ただし、コンテンツをその中に配置するのではなく、スクリプトとスタイルで通常行われるように、別のリソースに配置します。 内部?記事:right.cacheには、バージョンを持つ接続されたリソースのインデックスのみがあります。



?記事:right.cache / content / version:123

?記事:right.cache /コメント/時間:2010-12-01

ライブ/時間:2010-12-01

?スタイル:記事/バージョン:666

?スクリプト:記事/バージョン:333



バージョンを指定すると、リソースのハードキャッシングを設定できます。 反対に、インデックスファイルの場合、リクエストごとに変更されているかどうかをチェックする必要性を設定します。



このような組織は、新しいコメントが表示されたときに記事を再読み込みする必要がないことを保証します。 逆に、記事を変更する場合、コメントツリー全体をオーバーロードする必要はありません。 また、頻繁に変化するライブブロードキャストのために、すべてのコンテンツを新しい方法で読み込む必要はなく、st音を立てる必要もありません;-)



検索エンジンがリソースへのリンクを見て、それらにインデックスを付けることができることが重要です。 しかし、検索から、人々は特定のリソース、さらにはその特定のバージョンに到達します。 したがって、リソースは、直接リンクを介してダウンロードされるかどうかを判断する必要があり、ダウンロードされる場合は、クライアント手段によるロード後にインデックスにリダイレクトされます。 リソースの現在のバージョンが変更されていない場合、キャッシュから取得されます。 変更されている場合、新しいバージョンがダウンロードされます。 実際、それほどひどい災害ではありません;-)



フレームとajaxを使用した実装は非常に一般的なので、HTMLインクルージョンを使用しましょう



インデックスは新しいものではありません。



<! DOCTYPE t:stylesheet [ <! ATTLIST t:stylesheet id ID # REQUIRED > ] > <br> <? xml-stylesheet type ="text/xsl" href ="#t:stylesheet" ? > <br> < t:stylesheet id ="t:stylesheet" version ="1.0" xmlns:t ="http://www.w3.org/1999/XSL/Transform" > <br> < t:output doctype-public ="-//W3C//DTD XHTML 2.0//EN" doctype-system ="http://www.w3.org/MarkUp/DTD/xhtml2.dtd" /> <br> < t:template match =" @* | node() " > <br> < t:copy > <br> < t:apply-templates select =" @* | node() " /> <br> </ t:copy > <br> </ t:template > <br> < t:template match =" *[ @src and contains( @srctype, 'xml' ) ] " > <br> < t:copy > <br> < t:apply-templates select =" @* " /> <br> < t:apply-templates select =' document( @src )//html/body/* ' /> <br> </ t:copy > <br> </ t:template > <br> < t:template match =" / " > <br> < t:apply-templates select =" document( '#t:stylesheet' )//html " /> <br> </ t:template > <br> < t:template name ="content" > <br> < html > <br> < head > <br> < title > Article with comments </ title > <br> < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> <br> < link href ="?style:article/version:666" type ="text/css" rel ="stylesheet" /> <br> < script src ="?script:article/version:333" type ="text/javascript" ></ script > <br> </ head > <br> < body > <br> < section src ="?article:right.cache/content/version:123" srctype ="text/xml" > <br> < a href ="?article:right.cache/content/version:123" > article content </ a > <br> </ section > <br> < section src ="?article:right.cache/comments/time:2010-12-01" srctype ="text/xml" > <br> < a href ="?article:right.cache/comments/time:2010-12-01" > article comments </ a > <br> </ section > <br> < section src ="?live/time:2010-12-01" srctype ="text/xml" > <br> < a href ="?live/time:2010-12-01" > live content </ a > <br> </ section > <br> </ body > <br> </ html > <br> </ t:template > <br> </ t:stylesheet >







ただし、リソースには他のテンプレートがあります。



<! DOCTYPE t:stylesheet [ <! ATTLIST t:stylesheet id ID # REQUIRED > ] > <br> <? xml-stylesheet type ="text/xsl" href ="#t:stylesheet" ? > <br> < t:stylesheet id ="t:stylesheet" version ="1.0" xmlns:t ="http://www.w3.org/1999/XSL/Transform" > <br> < t:output doctype-public ="-//W3C//DTD XHTML 2.0//EN" doctype-system ="http://www.w3.org/MarkUp/DTD/xhtml2.dtd" /> <br> < t:template name ="content" > <br> < html > <br> < head > <br> < title > Article content </ title > <br> < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> <br> </ head > <br> < body > <br> < h > Article content </ h > <br> </ body > <br> </ html > <br> </ t:template > <br> < t:template match =" / " > <br> < t:element name ="meta" > <br> < t:attribute name ="http-equiv" > refresh </ attribute > <br> < t:attribute name ="content" > 0;url=?article:right.cache </ attribute > <br> </ t:element > <br> </ t:template > <br> </ t:stylesheet >





ブラウザからの直接リクエストはリダイレクトされますか?記事:right.cache

検索エンジンはコンテンツを受信し、インデックスを作成します。



All Articles