[prev in list] [next in list] [prev in thread] [next in thread] 

List:       konq-bugs
Subject:    Bug#39711: kio-http ignores HTTP cache control commands
From:       Andrew Kohlsmith <akohlsmith () benshaw ! com>
Date:       2002-03-24 16:32:24
[Download RAW message or body]

> If that works then we should probably use an extra state "Expired" instead
> of "Uncacheable" or use m_expireDate for this somehow, because Uncacheable
> currently means "It is too big for the cache, don't keep it". But we
> certainly don't want to load it again if it still happens to be in the
> cache. "Expired" would then mean "It's cached but we should fetch a new
> version when we need one".
>
> Ideally we should also distinguish between a normal page load and accessing
> the history, because when we go back in the history we should ignore
> "Expired".

Thank you for all the help; attached is my diff.

I found that requestImage has to check for both Uncacheable and Expired 
states; using Expired alone didn't do me any good because the image I'm 
retrieving was 245k and was marked uncacheable anyway, but requestImage() was 
still grabbing it because finish() changed the state from Expired to 
Uncacheable.  :-)

I will try to incorporate history and expire dates shortly.  Again, thank you 
for all your help.   KDE is an incredible desktop environment, and you 
personally have an incredible response time.  Thank you.

Regards,
Andrew


 
["khtml-cache.diff" (text/x-diff)]

diff -ur kdelibs-orig/khtml/misc/loader.cpp kdelibs/khtml/misc/loader.cpp
--- kdelibs-orig/khtml/misc/loader.cpp	Sat Feb  2 20:47:10 2002
+++ kdelibs/khtml/misc/loader.cpp	Sun Mar 24 11:26:44 2002
@@ -60,23 +60,33 @@
 
 void CachedObject::finish()
 {
-    if( m_size > MAXCACHEABLE )
-    {
-        m_status = Uncacheable;
-        //Cache::flush(true); // Force flush.
-    }
-    else
-        m_status = Cached;
-    KURL url(m_url.string());
-    if (m_expireDate && url.protocol().startsWith("http"))
-    {
-        KIO::http_update_cache(url, false, m_expireDate);
+ kdDebug(6060) << "CachedObject::finish() entry: status is " << m_status << endl;
+ if(m_size > MAXCACHEABLE)
+   {
 #ifdef CACHE_DEBUG
-        kdDebug(6060) << " Setting expire date for image "<<m_url.string()<<" to " \
<< m_expireDate << endl; +   kdDebug(6060) << "CachedObject::finish() m_size(" << \
m_size << ") > MAXCACHEABLE (" << MAXCACHEABLE << "), setting m_status to \
Uncacheable!" << endl;  #endif
-    }
+   m_status = Uncacheable;
+   }
+ else
+   if(m_status == Pending)				// only update status if still pending
+     m_status = Cached;
+
+ KURL url(m_url.string());
+ if(url.protocol().startsWith("http"))
+   {
+   KIO::http_update_cache(url, m_expireDate ? false : true, m_expireDate);
+
 #ifdef CACHE_DEBUG
-    else kdDebug(6060) << " No expire date for image "<<m_url.string()<<endl;
+   if(m_expireDate)
+     kdDebug(6060) << " Setting expire date for image "<<m_url.string()<<" to " << \
m_expireDate << endl; +   else
+     kdDebug(6060) << " No expire date for image "<<m_url.string()<<endl;
+#endif
+   }
+
+#ifdef CACHE_DEBUG
+ kdDebug(6060) << "CachedObject::finish() exit: status is " << m_status << endl;
 #endif
 }
 
@@ -1034,6 +1044,16 @@
   }
   else
   {
+
+ if(job->queryMetaData("no-cache") == "true")
+   {
+#ifdef CACHE_DEBUG
+   kdDebug(6060) << "Loader::slotFinished() object should not be cached..." << endl;
+#endif
+   job->addMetaData("cache", "reload");
+   r->object->setStatus(CachedObject::Expired);
+   }
+
       r->object->data(r->m_buffer, true);
       emit requestDone( r->m_docLoader, r->object );
   }
@@ -1207,10 +1227,14 @@
     CachedObject *o = 0;
     if (!reload)
         o = cache->find(kurl.url());
-    if(!o)
+    if(!o || (o->status() == CachedObject::Expired) || (o->status() == \
CachedObject::Uncacheable))  {
 #ifdef CACHE_DEBUG
         kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
+ 	if(o)
+	  kdDebug(6060) << " o->status() is " << o->status() << endl; 
+	else
+	  kdDebug(6060) << " object doesn't exist" << endl;
 #endif
         CachedImage *im = new CachedImage(dl, kurl.url(), reload, _expireDate);
         if ( dl && dl->autoloadImages() ) Cache::loader()->load(dl, im, true);

diff -ur kdelibs-orig/khtml/misc/loader.h kdelibs/khtml/misc/loader.h
--- kdelibs-orig/khtml/misc/loader.h	Tue Mar  5 18:13:27 2002
+++ kdelibs/khtml/misc/loader.h	Sun Mar 24 10:01:24 2002
@@ -94,6 +94,7 @@
             Pending,      // only partially loaded
 	    Persistent,   // never delete this pixmap
 	    Cached,       // regular case
+	    Expired,      // URL has expired; fetch it new again 
 	    Uncacheable   // to big to be cached,
 	};  	          // will be destroyed as soon as possible
 


_______________________________________________
Konq-bugs mailing list
Konq-bugs@mail.kde.org
http://mail.kde.org/mailman/listinfo/konq-bugs

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic