Environmental variables are cached by Pollen
#86
Closed
opened 9 years ago by fasiha
·
5 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Borrowing a page from the web development crowd, I'm using an environmental variable called
TESTING
to control behavior of my Pollen build. When I'm testing on my local machine, I want the rendered output to use a local copy of MathJax, e.g., but for production, I want it to point to the CDN. If my Pollen markup file contains◊(define-meta development (getenv "TESTING"))
, then my template canselect-from-metas
and detect when I run$ TESTING=1 raco pollen render file.html
vs justraco pollen …
.However, for this to work in practice, I have to delete the pollen-cache directory. It would appear that the result of
getenv
is cached and reused.I'm tempted to disable caching (I saw how to in one of these issues using a config module) because Pollen's CPU time is lower after I delete cache than if I don't (180 vs 260), but I thought I should send a note and see if there was a better way forward.
Yes, disabling the compile cache in your
pollen.rkt
will work:I’ve also just pushed an update that makes the cache look for a
POLLEN
environment variable (= more general designator thanTESTING
). So this:will not compile the same way as this:
Meaning, if you use the
POLLEN
environment variable, you needn’t disable the cache.As for all the other environment variables … this runs into the general problem of cache invalidation. You can always create a new dependency from afar. The only way for the Pollen cache to be certain that something hasn’t changed is to compile afresh every time (which of course would be the equivalent of not caching at all).
So for the cache to be useful, there has to be a limit on the horizon of dependency checking. For those who need true unfettered dynamism, disabling the cache is the solution.
BTW there is also a render cache, so the whole cache-disabling config would be this:
Most awesome, thank you good sir 👍!
I use this a lot now. Good idea!