* wrap/python/ajax/spot.in: Touch the directory containing
the cached result for the requests. So that it survives the browser's cache. (finish): Prune the cache only once per hour, and only eraes files that are older than 2 hours.
This commit is contained in:
parent
8059047b21
commit
c42d55e6b1
2 changed files with 16 additions and 5 deletions
|
|
@ -1,3 +1,11 @@
|
||||||
|
2011-06-10 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
|
* wrap/python/ajax/spot.in: Touch the directory containing
|
||||||
|
the cached result for the requests. So that it survives
|
||||||
|
the browser's cache.
|
||||||
|
(finish): Prune the cache only once per hour, and only eraes
|
||||||
|
files that are older than 2 hours.
|
||||||
|
|
||||||
2011-06-09 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
2011-06-09 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
* wrap/python/ajax/ltl2tgba.html: Add focus on the formula field
|
* wrap/python/ajax/ltl2tgba.html: Add focus on the formula field
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import os
|
||||||
script = os.environ.has_key('SCRIPT_NAME')
|
script = os.environ.has_key('SCRIPT_NAME')
|
||||||
|
|
||||||
if script:
|
if script:
|
||||||
print "Cache-Control: max-age=3600"
|
print "Cache-Control: max-age=3600" # One hour.
|
||||||
print "Content-Type: text/html"
|
print "Content-Type: text/html"
|
||||||
print
|
print
|
||||||
|
|
||||||
|
|
@ -43,6 +43,9 @@ if qs:
|
||||||
# Is this a request we have already processed?
|
# Is this a request we have already processed?
|
||||||
cache = open(cachename, "r", 0)
|
cache = open(cachename, "r", 0)
|
||||||
print cache.read()
|
print cache.read()
|
||||||
|
# Touch the directory containing the files we used, so
|
||||||
|
# it that it survives the browser's cache.
|
||||||
|
os.utime(imgprefix)
|
||||||
exit(0)
|
exit(0)
|
||||||
except IOError:
|
except IOError:
|
||||||
# We failed to open the file.
|
# We failed to open the file.
|
||||||
|
|
@ -112,16 +115,16 @@ def finish(kill = False):
|
||||||
stamp = imgdir + '/cache.stamp'
|
stamp = imgdir + '/cache.stamp'
|
||||||
now = time.time()
|
now = time.time()
|
||||||
try:
|
try:
|
||||||
# Prune at most once every 15 minutes
|
# Prune at most once every hour
|
||||||
if now - os.path.getmtime(stamp) < 900:
|
if now - os.path.getmtime(stamp) < 3600:
|
||||||
exit(0)
|
exit(0)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
# Erase all directories that are older then 60 minutes, and all
|
# Erase all directories that are older than 2 hours, and all
|
||||||
# files that have only one hardlinks. Files that have more than
|
# files that have only one hardlinks. Files that have more than
|
||||||
# one hardlinks are referenced to by directories; so the hardlink
|
# one hardlinks are referenced to by directories; so the hardlink
|
||||||
# count will decrease when the directory is purged.
|
# count will decrease when the directory is purged.
|
||||||
os.system('find ' + imgdir + ' -mindepth 1 -maxdepth 1 -mmin +60 '
|
os.system('find ' + imgdir + ' -mindepth 1 -maxdepth 1 -mmin +120 '
|
||||||
+ '\( -type d -o -links 1 \) -exec rm -rf {} +')
|
+ '\( -type d -o -links 1 \) -exec rm -rf {} +')
|
||||||
# Create or update the stamp so we know when to run the next prune.
|
# Create or update the stamp so we know when to run the next prune.
|
||||||
open(stamp, "w", 0)
|
open(stamp, "w", 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue