Created
January 4, 2018 19:04
-
-
Save sangupta/428ee601312602b3afc7fe517f704f13 to your computer and use it in GitHub Desktop.
Python script to serve local files with caching disabled.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import http.server | |
class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_my_headers() | |
http.server.SimpleHTTPRequestHandler.end_headers(self) | |
def send_my_headers(self): | |
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") | |
self.send_header("Pragma", "no-cache") | |
self.send_header("Expires", "0") | |
if __name__ == '__main__': | |
http.server.test(HandlerClass=MyHTTPRequestHandler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment