untangled

NEW CHANNEL: #fulcro
2016-08-17T18:20:18.000580Z

slightly off topic: my production javascript files are being cached, so that when I deploy a new app, the clients load stale SPAs until they invalidate their cache, any suggestions? I see wrap-not-modified middleware is in place https://github.com/untangled-web/untangled-server/blob/master/src/untangled/server/impl/components/handler.clj#L164 i thought that this handled cache invalidation, but I guess not

2016-08-17T18:21:21.000582Z

i know one of the main solutions is to append version number to JS filename / as a query param

2016-08-17T18:29:12.000583Z

Maybe hacky, but what we've been doing is linking to all assets with a git tag in the url (like: ["/assets/" :asset-tag "/application.js"]) which we under the hood just ignore and rewrite to /assets/application.js

2016-08-17T18:29:32.000584Z

So then we can make the caching headers far-future

2016-08-17T18:29:39.000585Z

Because every deploy will change it

2016-08-17T18:30:06.000586Z

nice like it

2016-08-17T18:30:11.000587Z

thanks

2016-08-17T18:31:12.000588Z

Technically clojure doesn't know that the asset-tag is a git sha - we set it as an environment variable in our deploy setup, but not sure if that's really a detail that matters other than it made it easier to script than requiring a git clj library

2016-08-17T18:31:41.000589Z

right, yah, i would be very hesitant to add a dependency on git

2016-08-17T18:33:08.000590Z

you could even do md5sum of the jar file and pass that as env var

2016-08-17T18:33:44.000591Z

Yeah, whatever wouldn't change - our deploy is currently git dependent, so that seemed like a reasonable approach.

2016-08-17T18:34:32.000592Z

Making it environment variable based did make it a lot easier to mess around with to test it was working as expected (and let us set a development only tag "0" that doesn't get caching headers).

2016-08-17T18:35:49.000594Z

what's weird to me is that i thought wrap-not-modified middleware looks at the timestamp of the file on disk, and compares that timestamp of file on clients disk

2016-08-17T18:36:01.000595Z

and that this would invalidate the cache if I modified my javascript file

2016-08-17T18:36:09.000596Z

maybe i don't understand the middleware well enough

2016-08-17T18:37:11.000597Z

i find it strange that this hack is required at all, that a ring server can't work with the client to invalidate files that have changed on the server

2016-08-17T18:37:14.000598Z

Relying just on not-modified requires a round trip to the server every time, which is why we also added Cache Control headers for our tagged requests

2016-08-17T18:38:23.000599Z

ok I think I get it now

2016-08-17T18:38:49.000600Z

Looks like wrap-not-modified still wants you to do the heavy lifting anyway

2016-08-17T18:39:13.000601Z

"Middleware that returns a 304 Not Modified from the wrapped handler if the handler response has an ETag or Last-Modified header, and the request has a If-None-Match or If-Modified-Since header that matches the response" ^ so you have to put your own ETag and Last-Modified values into headers for it to work

2016-08-17T18:39:59.000602Z

Though you'd think the middleware for serving static assets would do that

2016-08-17T18:39:59.000603Z

that's assuming the client even makes a request for a file it has cached

2016-08-17T18:40:11.000604Z

which I guess it will only do once TTL has been reached

2016-08-17T18:40:19.000605Z

the max-age value

2016-08-17T18:40:53.000606Z

Yeah, we set it up the way we did so we can make max-age a year so it never has to check in

2016-08-17T18:41:06.000607Z

(Unless you reload and the html links to a new js file)

tony.kay 2016-08-17T18:51:59.000608Z

For anyone that has had problems with rendering and post-mutation (on data loads): I think I discovered a bug where post-mutations are not causing re-renders. I'm going to fix it (for now) by forcing a root re-render in the app when there are post mutations. This will be in 0.5.5-SNAPSHOT shortly.

tony.kay 2016-08-17T18:55:22.000609Z

That fix has been pushed to clojars on the snapshot

2016-08-17T19:00:01.000610Z

Is snapshot going to release at some point? I know there was another fix on there for https://github.com/untangled-web/untangled-client/issues/21

tony.kay 2016-08-17T19:00:46.000612Z

advanced optimizations is still not quite right with Om itself

tony.kay 2016-08-17T19:01:03.000613Z

The fixes going on there will affect that, I believe

2016-08-17T19:01:12.000614Z

Ah, I see.

tony.kay 2016-08-17T19:01:12.000615Z

(and will affect our implementation)

tony.kay 2016-08-17T19:01:29.000616Z

basically anything declared "static" is getting killed by Closure

tony.kay 2016-08-17T19:01:58.000617Z

alpha42 should fix that, which will let us clean up some code and have that work (hopefully)

tony.kay 2016-08-17T19:02:08.000618Z

for now, use whitespace or simple

tony.kay 2016-08-17T19:02:29.000619Z

My understanding is that this is actually a bug in Closure we're working around until it gets fixed.

2016-08-17T19:07:55.000620Z

Wow, the rabbit hole goes even deeper than I realized.

anmonteiro 2016-08-17T19:25:28.000621Z

@therabidbanana: see https://github.com/omcljs/om/issues/729 for more info

👍 1
2016-08-17T20:16:40.000623Z

wow, nice

2016-08-17T23:16:09.000624Z

can I call load-field-action twice in the same mutation handler?

2016-08-17T23:16:19.000625Z

to load 2 different fields

tony.kay 2016-08-17T23:16:22.000626Z

yes

tony.kay 2016-08-17T23:16:31.000627Z

it just appends a load onto the sequential queue

2016-08-17T23:16:43.000628Z

perfect

tony.kay 2016-08-17T23:16:58.000629Z

the thing you pass to :remote triggers an attempt to process it

2016-08-17T23:17:06.000630Z

ahh