Submit

Back to the channels

#primate

  1. bot [ByteCode.News] Andrew Lombardi: Unit Tests are Not the Enemy - https://bytecode.news/posts/2026/10/andrew-lombardi-unit-tests-are-not-the-enemy
  2. bot [ByteCode.News] Arcana Reads Everything, and Then Some - https://bytecode.news/posts/2026/10/arcana-reads-everything-and-then-some
  3. blue dreamreal: good take by Lombardi there
  4. blue also, what kind of idiot just deletes unit tests...
  5. lioloc blue: Hey blue ! Just to remember, right now there is no package to help with caching in the browser right? Like for instance if you receive props and you wanted to cache those props for the next time the user visits the page, would there be a way to do this?
  6. lioloc Caching is a topic that's always been a bit tough for me to understand (backend vs browser)
  7. lioloc I usually just use packages like tanstack/query that handles the caching mechanisms for me for the browser, and since now I instead typically make the queries in the route, these are backend fetches right? So I can't cache those unless I use redis or something like that right?
  8. lioloc I'm trying to understand what would be the right mechanisms to use caching in Primate for both use cases:
  9. lioloc 1. You're doing a fetch in a route
  10. lioloc 2. You receive props and maybe you want to cache those (or do you need to instead use a query library on the frontend instead and do the call here instead?)
  11. blue hi lioloc
  12. blue can you describe the use case so it's easier to understand? when do you want to cache props? And if you're fetching in a route, that's already on the server, there you'd probably use a caching server like redis. There are plans for a @primate/kv package: https://repopack.com/project/primate/tasks/10
  13. blue but I think it'd be easier for me to offer you paths forward if I understand your actual use case
  14. dreamreal blue: revamped the primate build's topbar
  15. dreamreal it was getting gross
  16. blue good good
  17. blue dreamreal: release artifacts landed today in repopack; it turned out a bit more than I'd bargained for, but the model is strong, I think; it has products, channels, and releases; releases draw from job runs; and can be promoted to channels. Channels carry access levels (PUBLIC or PROJECT). products are, well, a single publishable entity
  18. lioloc blue: Let's say in a route I fetch: Races and pass them as a prop to Index.vue, races is an array of objects and maybe it can contain 100 results
  19. dreamreal Noice!
  20. blue so the `rp` cli is a "product"; it has channels (stable, unstable); and there are releases, either unassigned to any channel (in which case they are project-private), or assigned to a channel
  21. lioloc blue: This is small enough that it isn't an issue without caching I would assume. But let's say there are like 10000 races and I want the experience of the application to feel extremely rapid when I'm moving from page to page, so that I can come back to a previous tab
  22. blue lioloc: so you load 10k races at once and want to keep it in the browser tab's memory; and those 10k races never change?
  23. lioloc Let's say we want to control when they change, like maybe we want to refetch only after 5 minutes
  24. lioloc so they won't change for 5 minutes
  25. blue how would you feel about `response.page(props, { cache: { ttl: 60 /* seconds */ } })`?
  26. lioloc I'm not sure if keeping it in the browser's memory is the best answer btw, I'm just trying to get the fastest experience for a user
  27. blue and same for response.view
  28. lioloc that would be neat
  29. blue that would be transparent for you; the primate fetch-client would serialise the path, and cache on the serialised key
  30. blue the route itself would likely send something like `Primate-Cache: max-age=60` along the response
  31. blue as a header
  32. lioloc this is for browser caching or server side caching btw?
  33. blue browser caching
  34. blue props caching
  35. blue server side caching is the easier problem there because you can write a small cache yourself fairly easily. @primate/kv could help there but it's relatively trivial to do it yourself first. the client part isn't
  36. lioloc have you used something like tanstack/query? They also have the ability to invalidate a cache on the client, for optimistic updates, it can quickly can get confusing imo
  37. blue I haven't, but I was going to say that what I just purposed is a streamlined version of tanstack/query, where you don't need to manage the caching keys yourself
  38. blue from the documentation of tanstack/query, it appears terribly overengineered to me
  39. lioloc but what if you wanted to invalidate the cache once a user presses a button for instance?
  40. lioloc would be neat to be able to do that too
  41. blue then we should expose something on `primate/navigate`, probably
  42. blue https://primate-master.repopack.app/blog/primate-043#navigation-that-says-what-it-does
  43. nevet Primate — Primate 0.43: diamond migrations, deferred navigation and direct SQL
  44. blue maybe navigate.cache.clear()
  45. lioloc yeah would be neat
  46. lioloc I guess it's also because something like tanstack/query is used client side, not server side
  47. lioloc so you'll have multiple different query calls client side, each with their own cache key
  48. lioloc In primate's case, if you do the fetch in the route directly, wouldn't that mean that "Time to first paint" would be slower than in an app using tanstack/query to load things after?
  49. lioloc I mean naturally it would right? Cause you're fetching before serving the page. I'm thinking like the case of an app's dashboard for a logged in user for instance.
  50. blue That's a real distinction, however primate 0.43 will have response.defer
  51. blue which will allow you to use suspence boundaries or awaits inside clients
  52. blue suspense*
  53. blue https://primate-master.repopack.app/blog/primate-043#stream-page-data-during-navigation
  54. nevet Primate — Primate 0.43: diamond migrations, deferred navigation and direct SQL
  55. lioloc oh wow
  56. lioloc very neat
  57. lioloc if we introduce caching then maybe with defer you should also be able to invalidate a specific one?
  58. blue a specific prop?
  59. lioloc yeah
  60. lioloc cause if you have many props, perhaps you don't want everything to reload if you invalidate the cache
  61. lioloc I mean reload every prop
  62. lioloc what do you think?
  63. blue hm, selective browser updates can be hard
  64. blue I mean, we could potentially support navigate.cache.clear(key). but the mechanism behind it could turn out complicated
  65. blue if we have `response.page(props, { cache: { ttl: 60 /* seconds */ } })`, the browser would simply not call the route for 60 seconds
  66. blue but if we start breaking it down to props, that's a bit harder: the browser needs to call the route for *some* props, and the route suddenly might need to know not to care about some props. the complexity is higher
  67. lioloc yeah for sure
  68. blue lioloc: this is complex stuff. however, this could make sense:
  69. blue activity: response.defer(() => loadActivity(), { ttl: 600 })
  70. blue the lazy form means we can save actual work on the server, *for the particular client*
  71. blue without the lazy form, the gains aren't significant
  72. lioloc in essence what does that lazy call mean? as opposed to without the lazy call
  73. blue well, imagine we browse back to the page within the cache's lifetime. since we have a mixture between cached and non-cached prompts, primate has to issue a server request
  74. blue so it issues it with something like "I want this prop, but this prop is already cached and I don't need it)
  75. blue however, something like on this server:
  76. blue activity: response.defer(loadActivity(project)),
  77. blue will always do the work. loadActivity is essentially a promise-returning function, so the promise will return anyway on the server, and its output would be discard
  78. blue something like:
  79. blue response.defer(() => loadActivity(project), { ttl: 600 })
  80. blue can be prevented from running at all if the cache boundary holds
  81. blue s/prompts/props/
  82. blue the question whether page-level caching (so an option on response.page) is enough or whether you want the prop granularity
  83. blue I'm not sure having both mechanisms makes sense, that's a lot of different combinations needed to be accounted for
  84. blue if prop granularity is actually what you're looking for, then we should explore extending response.defer to accept a lazy function and a ttl
  85. blue if caching an entire page (=all its props) is what you're looking for, that's easier
  86. blue but I'm a bit hesitant to do both
  87. blue fwiw, the non-lazy form could still make a revisit *feel faster*. since the server work isn't blocking. but it happens anyway, that's a bit of a waste; maybe it's insignificant; though if we're talking about getting 10k records from a db, it might be
  88. blue dreamreal: would you also benefit from a client cache?
  89. blue specifically I think that if someone has loaded an article before, it might be useful to cache. but I don't know the exact model of how you serve articles. you serve the entire rendered html, no?
  90. lioloc what if it wasn't a response.defer function but just a "browserCache(" function (name irrelevant)? That way you can just decide whatever you want cached, whether it is the entire html or a specific portion, like props
  91. lioloc just spitballing ideas
  92. dreamreal I mean... maybe, but it would rely on a lot of retention
  93. blue yeah, but "whatever you want" cache still implies someone has to bookkeep that cache, and that's the complex part
  94. blue a different approach, lioloc, is a offer a `primate/query` or so
  95. blue https://dpaste.com/7NMKZMRM7
  96. blue but I feel this is perhaps more relevant for BCN than what you just described
  97. dreamreal Well, it presumes retention, still
  98. blue lioloc: maybe you can create a small example and I can play around with it
  99. blue yes dreamreal, caching is widely also known as retention
  100. dreamreal standard use on BCN is not a lot of interrelated post traffic, which annoys me but is reflected in traffic patterns
  101. blue thank you for stating the obvious :P
  102. dreamreal I'm not trying to state the obvious, I'm talking about whether that pattern makes sense for BCN, whose traffic patterns would NOT show a benefit as yet
  103. blue const response = await posts.get({ path: { slug }, cache: { ttl: 300 },
  104. blue });
  105. dreamreal You wanted me to look, I looked, damn it
  106. blue dreamreal: lioloc: what do we think about this?
  107. blue in one line: `const response = await posts.get({ path: { slug }, cache: { ttl: 300 }});`
  108. blue idk if any of those ideas seems coherent
  109. dreamreal sure
  110. dreamreal I don't have a problem with it at all, it just wouldn't affect BCN :D
  111. blue well you know me, I'm loath to add things that are over-engineered, or complicated to understand or use
  112. dreamreal I don't think it's overengineered or difficult to understand
  113. dreamreal in fact I think its' really easy to understand
  114. blue which of the five options I offered?
  115. dreamreal The one that seemed to make sense to me was https://dpaste.com/7NMKZMRM7
  116. blue oh
  117. blue dreamreal: flog is live and installable at https://flog.run
  118. nevet flog — predictable JavaScript package management
  119. blue (using repopack release primitives)
  120. blue I will also publish an sdk for releases at @repopack/release; do you need one for java/kotlin as well?
  121. dreamreal blue: what would primate's BCN build look like with flog?
  122. dreamreal should have a "conversion from those other stupid package managers" section
  123. dreamreal java's a much harder climb because of maven repositories
  124. blue dreamreal: well, flog is currently mostly for npm; but the commands aren't js specific. the question is what do you need / what do you expect the workflow to be; generally, flog works like this:
  125. blue flog add / remove: adds or removes a dependency
  126. blue flog upgrade: upgrades dependencies (interactively)
  127. blue flog lock: create a lockfile
  128. blue flog install: materialises a lockfile
  129. blue if those primitives are transferable to maven, then there is no reason flog wouldn't be able to manage maven projects / pom.xml projects
  130. blue (flog add/remove/upgrade also changes a lockfile)
  131. dreamreal maven IS a lockfile, there're analogs but they're not esp applicable in the space
  132. blue dreamreal: just to be clear, you're looking to replace maven on the kotlin/java app, or pnpm on the primate-ui app, or both?
  133. dreamreal pnpm mainly, although it actually used npm itself unless you changed it
  134. blue oh ok, then it's different from what I thought
  135. blue flog should be able to replace pnpm/npm 1:1 and be much faster
  136. dreamreal *nod* if you want to, try it on ui-primate
  137. dreamreal good real-world-ish project
  138. blue ya

Search posts