2016-04-28 9 views
2

私はPythonでWebアプリケーションを持っていますが、Webサーバーはweb.pyで実装されています。HTTPヘッダーを無視して、web.py Webサーバーでキャッシングを無効にする

しかし、ブラウザが/static/index.htmlのWebサーバーでリクエストを送信すると、httpヘッダーに「IF-MATCH-NONE」と「IF-MODIFIED-SINCE」フィールドが含まれます。サーバーは、前回からhtmlページリクエストが変更されているかどうかを確認します(http:304 - Not Modifiedのサーバーレスポンス)...

どのようにしても、それは変更されていませんか?

ウェブサーバーのコードは次のとおりです。

import web 

urls= (
    '/', 'redirect', 
    '/static/*','index2', 
    '/home/','process' 
) 

app=web.application(urls,globals()) 


class redirect: 
     def GET(self): 
       ..    
       return web.redirect("/static/index.html") 

     def POST(self): 
       .. 
       raise web.seeother("/static/index.html") 

class index2: 
    def GET(self): 
     ... 
       some checks 
       .... 


if __name__=="__main__": 
    app.run() 
+0

、あなたはしばらくの間、「キャッシュを無効にするために、一般的なWebブラウザを設定することができますデベロッパーコンソール "が開いています。これは私にとっては十分だった。 – Gerard

答えて

0

あなたは応答ヘッダーでCache-Controlフィールドを追加する必要があります。たとえば

web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store") 

:その場しのぎの対策として

import web 

urls = ("/.*", "hello") 
app = web.application(urls, globals()) 

class hello(object): 
    def GET(self): 
     web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store") 
     return "Hello, world!" 

if __name__ == "__main__": 
    app.run() 
関連する問題