-
-
Notifications
You must be signed in to change notification settings - Fork 62
Update Kiwix-serve cache strategy #650
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
Comments
@veloman-yunkan I want to make a new attempt to sortout this problem of cache. Because the problem is broader than the API or Etag, I have closed #598, but thank you very much again for your explanation which are perfectly correct I think now. Would you be able please to assess this ticket and tell me if you disagree with something? Or maybe you would have an other approach to do it better? |
While you are waiting and interacting with @mgautierfr on #679 and I suspect it might take weeks ; I would really appreciate to have you looking at this ticket. |
@kelson42 OK, will do. |
This presents some maintenance challenge. kiwix-serve static resources are referenced in other static resources. For example, libkiwix/static/templates/index.html Lines 41 to 43 in ce24b1f
By adopting this scheme, whenever we update a static resource and change its unique id, we must make sure that all relative URLs pointing to that resource are updated too. Without automated frontend testing we will need to be careful in order to prevent mismatches between the resource ids and the cross references in sibling resources. I will try to figure out how to circumvent this difficulty. |
From this comment, I'm not 100% sure we have a common understanding about how to do this "cache busting". Whatever the value of From the technical side the should probably be a random string given by Meson to the compiler (like the version number) and it should be then set as template value and replaced accordingly. It does not really matter if we have a new |
@kelson42 I never said that the solution won't work. My point was that a straightforward implementation will add some maintenance headache. For example,
We can change it to
and then, when we modify
and so on. I am looking for an approach that will work automatically. P.S. I reread my previous comment and found the sentence which suggested that I doubted the viability of the proposed solution. I wrote
Indeed, if in the server we simply ignore the |
What about the following scheme? The quasi-revision¹ of a resource can be obtained automatically by the following command:
When new commits affecting We can have a script that preprocesses the templates in |
OK
I think it is better to to that in meson and C++. Your approach seems less clean and robust to me... but you are the dev. and as long as it works and @mgautierfr agree with it, this is fine to me. |
Relying on |
The solution to static resource versioning must not be fooled by a |
How should this interact with the decoration of libkiwix/static/templates/taskbar_part.html Lines 5 to 20 in 5c38300
|
This may be a good time to once again reconsider #394 |
@veloman-yunkan Your two last comments are pertinent IMO. In this ticket I simply have chosen to ignore the fact that part (taskbar) of each article is chrome and is conceptually different... and that treating it in an undifferentiated manner would lead to unexpected behaviours. This is just a limitation of the current design IMO. See my comment at #394 (comment). #394 is part of the current milestone |
Stepping into the discussion as we are revamping library.kiwix.org's frontend (reverse proxy). As discussed with @kelson42, we'd want kiwix-serve to respond properly and not hack its responses into the proxy. From what I understand, here's to do:
|
@rgaudin Thx, it clarifies the behaviour with non-static content and seems correct me. Hopefuly for @veloman-yunkan and @mgautierfr as well? |
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions. |
@veloman-yunkan Now, that the fix to have an iframe based taskbar runs the last revirw ozeration, could we go fotward with this ticket? |
@kelson42 Yrs, qe cuolf 😄 |
@veloman-yunkan Looks like we are now back to this ticket. Do you need to split it in smaller pieces? |
@kelson42 I am starting to work on it and will file subtickets as needed. |
Kiwix serve delivers many types of content:
For each type, here is how we want to cache:
Which implies 3 different strategies...
ZIM content
ZIM content does give us no freedom about the URLs calls and we have no way to garanty that what is available at the URL at two different times is the same content. Therefore the content can be cached but must be revalidate (with
Etag
issued from the ZIM ID). To avoid a systematic revalidation we can set a max-age of one hour likeCache-Control: max-age=3600, must-revalidate
.Kiwix-serve static content
This is the easier case, we need to "cache busting", for example by adding
?UNIQUE_ID
at the end of the URL of any of the resources. ThisUNIQUE_ID
should be fixed at compilation time.Cache-Control: max-age=31536000, immutable
then should be enough (so no other related HTTP headers, likeEtag
,Last-Modified
orExpires
).Kiwix-serve dynamic content
The dynamic content is consistent and can be cached as long as the library is not updated or the server restarted. I would propose to force systematically revalidation with an
Etag
which is changed each time the internal library is changed. The cache policy would look likeCache-Control: max-age=0, must-revalidate
.The text was updated successfully, but these errors were encountered: