pyvec / naucse

A server for open course material
Other
2 stars 9 forks source link

Add UNIX timestamp to generated website. #32

Closed Kobzol closed 4 years ago

Kobzol commented 4 years ago

Adds a UNIX timestamp to the generated website, so that it can be used by remote sites (like https://github.com/messa/pyladies-courseware) to invalidate their caches if something changes.

The timestamp is global for the whole website to keep it simple (pyladies-courseware fetches the whole website in one go, so this change is enough to solve its caching problem).

If you want to use a hash instead, we could add a simple postprocessing step to naucse, which would hash the v0 directory after the website is frozen and create a file containing the hash inside the v0 directory.

Related issues: https://github.com/pyvec/naucse/issues/28, https://github.com/messa/pyladies-courseware/issues/165

encukou commented 4 years ago

I'd rather add an "etag" to individual courses (https://github.com/pyvec/naucse/issues/28). A timestamp for the whole page will work for a statically generated website, but it would be harder to implement is naucse is dynamic.

Kobzol commented 4 years ago

It would be better to do it for courses individually, but right now if I understand correctly, naucse is generated as a static website and projekty.pyladies.cz fetches all data and can't check courses individually. So the timestamp is a quick fix (let's say for the current spring courses), until the system is reworked.

encukou commented 4 years ago

For the static website you might be able to use commit.sha from https://api.github.com/repos/pyvec/naucse.python.cz/branches/gh-pages

encukou commented 4 years ago

See #33 for the "etag" solution.

Kobzol commented 4 years ago

Ok, let's skip the intermediate step and use etags directly. This will require a larger rewrite of pyladies-courseware, but at least we don't have to make the change in multiple steps. Thanks! I'm therefore closing this issue.