Mercurial > SimpleWebPresenter
comparison Page.inc @ 99:d98e315308cd
Improved caching of flag and sitemap.
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Sun, 14 Sep 2014 21:11:27 +0200 |
| parents | 2370f4450983 |
| children | 0a33803ee026 |
comparison
equal
deleted
inserted
replaced
| 98:f2d52fed708c | 99:d98e315308cd |
|---|---|
| 150 abstract function cacheCheck(); | 150 abstract function cacheCheck(); |
| 151 | 151 |
| 152 /** | 152 /** |
| 153 * Generates an appropriate response to the request. | 153 * Generates an appropriate response to the request. |
| 154 * | 154 * |
| 155 * Eg. 302 NOT CHANGED, error message or the actual content | 155 * Eg. 304 NOT CHANGED, error message or the actual content |
| 156 */ | 156 */ |
| 157 function genPage() | 157 function genPage() |
| 158 { | 158 { |
| 159 if ($this->cacheCheck()) { | 159 $cacheable = $this->cacheCheck(); |
| 160 $this->cache->CheckHttpModified(); | 160 if ($cacheable == Cacheable::YES) { |
| 161 if (!CheckHttpModified($this->cache)) | |
| 162 return false; | |
| 161 } | 163 } |
| 162 $res = $this->generateContent(); | 164 $res = $this->generateContent(); |
| 165 if ($cacheable == Cacheable::UNDETERMINED) { | |
| 166 $cacheable = $this->cacheCheck(); | |
| 167 if ($cacheable == Cacheable::YES) { | |
| 168 if (!CheckHttpModified($this->cache)) | |
| 169 return false; | |
| 170 } | |
| 171 } | |
| 172 | |
| 163 if ($this->mayValidate()) { | 173 if ($this->mayValidate()) { |
| 164 /* | 174 /* |
| 165 $request = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | 175 $request = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
| 166 $validator = new OnlineUriValidator($request); | 176 $validator = new OnlineUriValidator($request); |
| 167 */ | 177 */ |
| 188 * Printing headers and content. | 198 * Printing headers and content. |
| 189 */ | 199 */ |
| 190 function display() | 200 function display() |
| 191 { | 201 { |
| 192 $res = $this->genPage(); | 202 $res = $this->genPage(); |
| 193 foreach ($res->headers as $header => $value) { | 203 if ($res) { |
| 194 header("${header}: ${value}"); | 204 foreach ($res->headers as $header => $value) { |
| 195 } | 205 header("${header}: ${value}"); |
| 196 print $res; | 206 } |
| 207 print $res; | |
| 208 } | |
| 197 } | 209 } |
| 198 | 210 |
| 199 | 211 |
| 200 } | 212 } |
| 201 ?> | 213 ?> |
