summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/cgi/cgiAppEngine.cpp26
-rw-r--r--project2/files/presenterCache.cpp11
2 files changed, 24 insertions, 13 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index d9948e4..28600b3 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -107,11 +107,6 @@ CgiApplicationEngine::process() const
if (TransformSourcePtr ts = currentStage.get<2>()) {
TransformSourcePtr final = finalTransformSource(ts);
ScopeObject emptyFinal([final] { final->clearTargets(); });
- final->addTarget(new CgiResult(header, IO,
- rs && rs->outputOptions ? rs->outputOptions->Encoding().as<std::string>() : OutputOptions::encoding), NULL);
- BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) {
- final->addTarget(p, NULL);
- }
boost::shared_ptr<std::fstream> ddd;
ostreamWrapper * osw = NULL;
ScopeObject removeDdd([ts, &osw] { if (osw) { ts->removeTarget(osw); } });
@@ -124,10 +119,25 @@ CgiApplicationEngine::process() const
ddd.reset();
}
}
- ts->doTransforms();
- BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) {
- p->flushCache();
+ if (outputCachingActive) {
+ BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) {
+ final->addTarget(p, NULL);
+ }
+ ts->doTransforms();
+ BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) {
+ p->flushCache();
+ }
+ if (rs->caches.front()->check(0)) {
+ ScopeObject emptyFinal([rs] { rs->caches.front()->clearTargets(); });
+ rs->caches.front()->addTarget(new CgiResult(header, IO,
+ rs && rs->outputOptions ? rs->outputOptions->Encoding().as<std::string>() : OutputOptions::encoding), NULL);
+ rs->caches.front()->doTransforms();
+ return;
+ }
}
+ final->addTarget(new CgiResult(header, IO,
+ rs && rs->outputOptions ? rs->outputOptions->Encoding().as<std::string>() : OutputOptions::encoding), NULL);
+ ts->doTransforms();
}
else {
header->render(IO);
diff --git a/project2/files/presenterCache.cpp b/project2/files/presenterCache.cpp
index 90c2bc9..6c21580 100644
--- a/project2/files/presenterCache.cpp
+++ b/project2/files/presenterCache.cpp
@@ -104,11 +104,12 @@ class FilePresenterCache : public PresenterCache {
f = openCacheFile(key);
safesys<StatCacheFile>(-1, fstat(*f, &st));
}
- if ((st.st_mtime < (time(NULL) - FilePresenterCache::CacheLife)) || (st.st_mtime < scriptMtime)) {
- unlink(getCacheFile().string().c_str());
- openCaches.erase(key);
- f.reset();
- return false;
+ if (scriptMtime != 0) {
+ if ((st.st_mtime < (time(NULL) - FilePresenterCache::CacheLife)) || (st.st_mtime < scriptMtime)) {
+ unlink(getCacheFile().string().c_str());
+ openCaches.erase(key);
+ return false;
+ }
}
myCache = f;
return true;