Item8731: Cache makes it impossible to view topic created on file system
Priority: Urgent
Current State: No Action Required
Released In: 1.2.0
Target Release: minor
Applies To: Engine
Component: PageCache
Branches:
Using trunk, I just made a copy (on the file system) of System.UserRegistration to Main web. Instead of showing me the new page in Main web, I got the "does not exist" page. The new topic was listed in WebIndex, but clicking also lead to the "not found" page. Clearing the browser cache did not help, only switching of Cache in configure.
Settings:
- {CacheManager}: DBD
- {MetaCacheManager}: DBD
- {Cache}{Compress}: on
--
ArthurClemens - 19 Mar 2010
Confirmed. We cache 404's and there is no "get a new copy" on the Web Topic Creator page.
In general, we should probably not cache any errors.
Patch:
diff --git a/core/lib/Foswiki.pm b/core/lib/Foswiki.pm
index 5c6d17e..5228e4b 100644
--- a/core/lib/Foswiki.pm
+++ b/core/lib/Foswiki.pm
@@ -874,8 +874,12 @@ sub writeCompletePage {
# Remove <nop> and <noautolink> tags
$text =~ s/([\t ]?)[ \t]*<\/?(nop|noautolink)\/?>/$1/gis;
- if ( $Foswiki::cfg{Cache}{Enabled}
- && ( $this->inContext('view') || $this->inContext('rest') ) )
+ if (
+ $Foswiki::cfg{Cache}{Enabled}
+ && ( !defined $this->{response}->status()
+ || $this->{response}->status() < 400 )
+ && ( $this->inContext('view') || $this->inContext('rest') )
+ )
{
$cachedPage = $this->{cache}->cachePage( $contentType, $text );
$this->{cache}->renderDirtyAreas( \$text )
Michael, can you confirm that this is acceptable?
--
GeorgeClark - 06 Jan 2015
That would be fine in general. However caching a "page does not exist" decision is sensible as well as there is substantial cpu required to decide on this condition. Caching makes even more sense in publicly installed Foswikies when changed urls are still crawled by bots consistently. So Foswiki should respond with a 404 using as few resources as possible.
Coming back to the original headline of this report Arthur was missing the fact that any cache - not only the page cache but also Foswiki's internal memory cache on various levels, dbcache, solr, a dbi store, you name it - needs to be updated or even completely invalidated as soon as you change the database underneath in a non-standard way circumventing the normal edit-save cycle.
I just checked the PageCaching docu, section "Refreshing the cache" and it clearly mentions the steps how to invalidate
all of the page cache.
As far as I see there isn't really an action left here, given that we decide on caching a 404 as well.
--
MichaelDaum - 06 Jan 2015
At a minimum every page should have the refresh cache link. We need to figure out why it's missing from the 404 -
WebTopicCreator topic
--
GeorgeClark - 06 Jan 2015