http://tinyurl.com/c995d - http://www.iiccmode.com/ хз шо то за сайт
А, щось я не те вставив
http://xmlhack.ru/texts/06/doing-http-caching-right/doing-http-caching-right.htmmod-cache звідси:
http://www.xhaus.com/alan/python/proxies.html#amit# A basic cache
# Saving: every time we see a page, we save it to something in /tmp/cache;
# Reusing: every time we see a request that doesn't have pragma: no-cache,
# we look in /tmp/cache for the document, and if it's there we serve that
# What to do about:
# Cache-control: private
# Cache-Control: No-Cache
# Also, watch for cookie changes
# Browser header ``pragma: no-cache'' is used both for bookmarks and
# for reload button, so how do we distinguish?? :(
from string import *
from proxy3_util import *
from proxy3_filter import *
import os
# Make sure the directory exists
try: os.mkdir('/tmp/cache')
except: pass
CONTENT = {} # URL -> content
class Cache(BufferSomeFilter):
BUFFER_LEN = 0 # We can't deal with filtering at all
page_content = None
def filter(self, s):
# Save everything that goes by
if not self.page_content:
# Insert the headers the first time through
self.page_content = [join(self.args['serverheaders'].headers,''), '\r\n']
self.page_content.append(s)
return s
def close(self):
BufferSomeFilter.close(self)
url = self.args['url']
page_content = join(self.page_content, '')
CONTENT[url]= page_content
print 'saving', url
def event_process_request(obj, site, document, request, headers):
if (find(headers.getheader('Pragma', ''), 'no-cache') < 0 and
not headers.getheader('Content-length', '') and
CONTENT.has_key(site+document)):
# We have the content, and it's not marked as "no-cache" by the browser
print 'reusing', site+document
obj.outfile.write('HTTP/1.0 200 OK\r\n')
obj.outfile.write(CONTENT[site+document])
return []
register_filter('*', 'text/html', Cache)
register_filter('*', 'text/plain', Cache)
register_filter('*', 'image/gif', Cache)
register_filter('*', 'image/jpg', Cache)