[Tilecache] Max-Age

Alexandre Dube adube at mapgears.com
Fri Mar 13 08:52:42 EDT 2009


Hi Linde,

# in Service.py :
...........
        if "HTTP_X_FORWARDED_HOST" in os.environ:
            host      = "http://" + os.environ["HTTP_X_FORWARDED_HOST"]
        elif "HTTP_HOST" in os.environ:
            host      = "http://" + os.environ["HTTP_HOST"]

        host += os.environ["SCRIPT_NAME"]
        req_method = os.environ["REQUEST_METHOD"]
        format, image = service.dispatchRequest( params, path_info, 
req_method, host )
        print "Cache-Control: public, max-age=604800" # <----------------
        print "Content-type: %s\n" % format

        if sys.platform == "win32":
            binaryPrint(image)
        else:
            print image
    except TileCacheException, E:
        print "Cache-Control: max-age=10, must-revalidate" # make the 
client reload
        print "Content-type: text/plain\n"
        print "An error occurred: %s\n" % (str(E))
..............

Best regards,

Alexandre

Linde Ackermans wrote:
> Dear Alexandre,  ( or someone else )
>
> Would you be so kind to specify a bit more where exactly you added the line
>      print "Cache-Control: public, max-age=86400" ( not the line number, but
> a bit of context )
> in the Service.py file ? 
> Thanks
>
> Linde Ackermans
>
>
> Alexandre Dube wrote:
>   
>> Hi list,
>>
>>   Is there a way to set tilecache to return images with a max-age so 
>> that the browser use local cache instead of having to request for tiles 
>> all the time (even if they are cached on server-side ) ?
>>
>>   I had to add this line to Service.py at line 291 to do this behavior :
>> print "Cache-Control: public, max-age=86400"
>>
>> -- 
>> Alexandre Dubé
>> Mapgears
>> www.mapgears.com
>>
>> _______________________________________________
>> Tilecache mailing list
>> Tilecache at openlayers.org
>> http://openlayers.org/mailman/listinfo/tilecache
>>
>>
>>     
>
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Tilecache mailing list