-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lemmy UI silently fills Firefox local storage (posts) without automatic deletion/cleaning #2792
Comments
I'd need someone with some expertise on why the service worker would make removing the cached images impossible. |
While I'm not particularly skilled with service workers, we have a dependency that should handle setting most of that stuff up automatically. From the webpack config: const clientConfig = {
// Some stuff not relevant here...
plugins: [
...base.plugins,
new ServiceWorkerPlugin({
enableInDevelopment: mode !== "development", // this may seem counterintuitive, but it is correct
workbox: {
cacheId: "lemmy",
include: [/(assets|styles|js)\/.+\..+$/g],
inlineWorkboxRuntime: true,
runtimeCaching: [
{
urlPattern: ({
sameOrigin,
url: { pathname, host },
request: { method },
}) =>
(sameOrigin || host.includes("localhost")) &&
(!(
pathname.includes("pictrs") || pathname.includes("static")
) ||
method === "POST"),
handler: "NetworkFirst",
options: {
cacheName: "instance-cache",
},
},
{
urlPattern: ({ url: { pathname, host }, sameOrigin }) =>
(sameOrigin || host.includes("localhost")) &&
pathname.includes("static"),
handler: mode === "development" ? "NetworkFirst" : "CacheFirst",
options: {
cacheName: "static-cache",
expiration: {
maxAgeSeconds: 60 * 60 * 24,
},
},
},
{
urlPattern: ({ url: { pathname }, request: { method } }) =>
pathname.includes("pictrs") && method === "GET",
handler: "StaleWhileRevalidate",
options: {
cacheName: "image-cache",
expiration: {
maxAgeSeconds: 60 * 60 * 24,
},
},
},
],
},
}),
],
}; It's been awhile since I've touched this stuff, so I don't remember much of the context behind the caching decisions. Please feel free to criticize the config. |
Minor Firefox debugging info: within the As I'd flushed my full storage as part of initial debugging, I'm now letting it fill back up again for a few days to try and capture a new |
Update: I'm starting to get the spidey-sense it might be
In the caches.sqlite, they indicate loading by service-worker.js and are in cache ID 3 (which based on other content seems to be a catchall with I intentionally opened every single post in new tabs and fully scrolled to load all comments today on the All front page, roughly Wed Nov 6 02:59:21 PM UTC 2024 or so and will check on content after another few days, including the 2 posts I mentioned above to see if they're still sitting in the local-storage cache. |
I think I confirm my findings from the above comment; capturing the latest
Others which seem to be sticky, in alpha order:
I was able to identify 74 compressed post items from my "click every post on the front All pages for awhile" on 2024-11-06 "stuck" in the cache, all with timestamps from
Sampling a lot of I think we have post / api data being cached in local storage which is escaping the expected (desired) expiration triggers and falling back to some internal default (I read somewhere Firefox uses up to 10GB per site when not instructed what to do). |
Requirements
Summary
I noticed under Firefox: Settings -> Privacy my local cookie/cache data was taking some 3G of space which felt off. I opened Manage Data, sorted by size and lo and behold lemm.ee (my home instance) was using all that space. I cleared the cache, verified empty in
about:cache
as empty yet the consumed lemm.ee space it was still listed. I had to resort to using the History function "forget this site" to actually clear out all used space.I'll try and present my findings, but I'm sort of guessing my way through this as an observer and end user, not a dev or instance admin. @sunaurus runs the instance and helps with Lemmy code, I hope they do not mind me tagging them into this issue.
Steps to Reproduce
about:cache
, restart FirefoxTechnical Details
In your local Firefox profile there exists the
storage/...
tree where each subdir is a named site (such as lemm.ee or lemmy.world, etc.) and several subdirs under that, with "default" being the one used in my observation. A quick look at the files sitting there reveals a lot of objects like this one:->
"snappy" is a compression format used by Firefox; a quick install of snappy-tools let me have a look at a copy of one of them, confirming it was a JPEG I had looked at moments ago (note I had to use the
-i
flag to ignore some checksum errors from rudimentary debugging):That said, it pulled right up in an image viewer as the JPEG. I then shut down Firefox, copied that same sqlite3 file to a test file (it's locked with WAL/SHM files while Firefox is running) and verified the chain of custody on that file after a quick look at the schema and following my nose:
It is here I must stop and see what your team thinks, as I do see what's happening logistically but am unsure what the expectation of either Firefox or Lemmy UI is to be; as an end user this "feels like" permanent local storage is being used/triggered by
service-worker.js
instead of it actually going to cache (thecache2/
subfolder, e.g.about:cache
view).I believe it a reasonable expectation as an end user that these images I'm looking at by the dozens if not hundreds are temporary, transient and should be in the cached data (as per
about:cache
etc.) and not being stored in site local storage which appears to be "forever" (requires manual Forget of the site to clear).Thank you!
Lemmy Instance Version
0.19.5
Lemmy Instance URL
https://lemm.ee/
The text was updated successfully, but these errors were encountered: