From d1da0e06de1d50e5246ea362ea8f2949b6a2a950 Mon Sep 17 00:00:00 2001 From: hallgren Date: Wed, 9 Apr 2014 17:51:25 +0000 Subject: PGF web service: add unlexers and enable client side caching Most PGF web API commands that produce linearizations now accept an unlexer parameter. Possible values are "text", "code" and "mixed". The web service now include Date and Last-Modified headers in the HTTP, responses. This means that browsers can treat responses as static content and cache them, so it becomes less critical to cache parse results in the server. Also did some cleanup in PGFService.hs, e.g. removed a couple of functions that can now be imported from PGF.Lexing instead. --- src/server/Cache.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/server/Cache.hs') diff --git a/src/server/Cache.hs b/src/server/Cache.hs index 8cb9135e2..d7c806783 100644 --- a/src/server/Cache.hs +++ b/src/server/Cache.hs @@ -1,4 +1,4 @@ -module Cache (Cache,newCache,flushCache,readCache) where +module Cache (Cache,newCache,flushCache,readCache,readCache') where import Control.Concurrent.MVar import Data.Map (Map) @@ -21,7 +21,10 @@ flushCache :: Cache a -> IO () flushCache c = modifyMVar_ (cacheObjects c) (const (return Map.empty)) readCache :: Cache a -> FilePath -> IO a -readCache c file = +readCache c file = snd `fmap` readCache' c file + +readCache' :: Cache a -> FilePath -> IO (UTCTime,a) +readCache' c file = do v <- modifyMVar (cacheObjects c) findEntry modifyMVar v readObject where @@ -35,4 +38,4 @@ readCache c file = x' <- case m of Just (t,x) | t' == t -> return x _ -> cacheLoad c file - return (Just (t',x'), x') + return (Just (t',x'), (t',x')) -- cgit v1.2.3