1:- module(bc_bust, [
2 bc_bust_token/1 3]).
13:- use_module(library(http/http_wrapper)). 14:- use_module(library(st/st_expr)). 15:- use_module(library(dcg/basics)). 16:- use_module(bc_router).
24bc_bust_token(Token):-
25 start_time(Token).
26
29
30:- dynamic(start_time/1). 31
32set_start_time:-
33 get_time(FloatTime),
34 Time is round(FloatTime),
35 retractall(start_time(_)),
36 asserta(start_time(Time)).
37
38:- set_start_time. 39
42
43http:request_expansion(RequestIn, RequestOut):-
44 select(path(PathIn), RequestIn, Request),
45 atom_codes(PathIn, CodesIn),
46 phrase(cache_busting_prefix, CodesIn, OutCodes),
47 atom_codes(PathOut, OutCodes),
48 RequestOut = [path(PathOut),cache_token(true)|Request],
49 debug(bc_bust, 'Rewrote cache bust prefixed path ~p', [PathIn]).
50
51cache_busting_prefix -->
52 "/t-", integer(_).
53
56
57:- bc_bust_token(Token),
58 st_set_global(cache_token, Token).
Client-side cache busting
This module provides client-side cache busting support by rewriting request paths that contain specifically formatted prefix. Adds
cache_token
global to simple-template. */