Skip to content
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

HTTP ETag #235

Open
johnjohndoe opened this issue Jan 12, 2024 · 5 comments
Open

HTTP ETag #235

johnjohndoe opened this issue Jan 12, 2024 · 5 comments

Comments

@johnjohndoe
Copy link
Contributor

johnjohndoe commented Jan 12, 2024

Context

The provided schedule.xml is fetched by the FOSDEM Schedule app for Android to render the conference program in the mobile app.
To avoid unneeded downloads of the schedule when unchanged the app reads the HTTP ETag of the response and adds it to each subsequent request. If the schedule has not changed a server supporting HTTP ETag would respond with an HTTP 304 NOT MODIFIED status code and an empty response payload.
Also, schedule update announcements are presented to the user of the app. These should not be shown when the schedule has not changed.

Current state

The server seems not to support HTTP ETag for the given URL:

$ curl -I -H "If-None-Match: " https://fosdem.org/2024/schedule/xml /dev/null 2>&1
HTTP/2 200 
server: nginx
date: Fri, 12 Jan 2024 09:09:07 GMT
content-type: text/xml; charset=utf-8
content-length: 1579543
last-modified: Fri, 12 Jan 2024 06:48:51 GMT
vary: Accept-Encoding
expires: Fri, 12 Jan 2024 09:14:07 GMT
cache-control: max-age=300
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
content-security-policy: default-src 'self'; script-src 'self' 'unsafe-inline'; media-src 'self' http: https:; img-src 'self' data: *.fosdem.org; object-src 'self'; style-src 'self' 'unsafe-inline'; 
accept-ranges: bytes

Request

Can you please add support for HTTP ETag to the webserver before/during/after the conference? I am mentioning all time frames because some conferences tend to archive their schedule as a static resource which then no longer supports HTTP ETag.

@johnjohndoe
Copy link
Contributor Author

@cbeyls, @Wilm0r fyi

@cbeyls
Copy link
Contributor

cbeyls commented Jan 12, 2024

For the record, you should be able to use HTTP If-Modified-Since with the date returned by the last-modified header to achieve the same effect as ETag: skip downloading the content if it hasn't changed.

@johnjohndoe
Copy link
Contributor Author

@cbeyls Thank you for the heads up! 👍 I wasn't aware that the app does not make use of this header. I have now implemented it.
Still, I would be interested to know if supporting ETags is considered best practice or not.

johnjohndoe added a commit to EventFahrplan/EventFahrplan that referenced this issue Jan 12, 2024
+ Add "schedule_last_modified" column to "meta" table.
  Increase "meta" database version.
+ Ensure default value is empty string. Otherwise, the app would crash on
  the next update in RealMetaDatabaseRepository/query/getString with a NPE.
+ Docs:
  + https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
  + https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
+ Related:
  + FOSDEM/website#235
  + https://git.cccv.de/hub/hub/-/issues/564
@johanvdw
Copy link
Member

@gerryd - you added etag off previously (April 2019).

+    custom_config: |
+      etag off; # Disable file-based ETags, we use Expires in a much more efficient way
+      #
+      expires 300s; # By default, set an expires on 5 minutes

Any reason I'm not aware of not to enable it again?

johnjohndoe added a commit to EventFahrplan/EventFahrplan that referenced this issue Jan 13, 2024
+ Add "schedule_last_modified" column to "meta" table.
  Increase "meta" database version.
+ Ensure default value is empty string. Otherwise, the app would crash on
  the next update in RealMetaDatabaseRepository/query/getString with a NPE.
+ Docs:
  + https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
  + https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
+ Related:
  + FOSDEM/website#235
  + https://git.cccv.de/hub/hub/-/issues/564
@gerryd
Copy link
Member

gerryd commented Jan 14, 2024

Good question. I'm not entirely sure, but I think I remember there were issues with the CSS sprites and caching.

johnjohndoe added a commit to EventFahrplan/EventFahrplan that referenced this issue Jan 18, 2024
+ Add "schedule_last_modified" column to "meta" table.
  Increase "meta" database version.
+ Ensure default value is empty string. Otherwise, the app would crash on
  the next update in RealMetaDatabaseRepository/query/getString with a NPE.
+ Docs:
  + https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
  + https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
+ Related:
  + FOSDEM/website#235
  + https://git.cccv.de/hub/hub/-/issues/564
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants