Local and Remote files

On load .lit determines the src and root and checks both local file system (testing/LightningFS) and the remote host (ie GitHub pages, or local/remote server) and compares last-updated (or Stat mtimeMs in the case of local filesystem)

The problem is, that deployment to GitHub pages results in a remote file that seems newer than the local file that created it.

Potential solutions

  • Disable (appropriately) GitHub Pages cache testing/log/2021-06-10
  • Read from api instead of pages static file server when Authenticated
    • Potentially read and write to gh-pages directly, eschewing Actions deployment entirely.
    • Currently reading and writing to GitHub api when token is available. Breaks reading generated files like : manifest.json
  • Compare hashes of the content stackoverflow crypto
  • store creation and modified date in frontmatter
txttest.txt< test.txt
Q
js
return lit.fs.readFile('/manifest.json')
js
return JSON.stringify(lit.utils.diff.diffLines(lit.stats.local.value, lit.stats.remote.value, {
  newlineIsToken: true,
}), null, 2)
txtUpdated 138.9w ago
[
  {
    "count": 51,
    "value": "# Local and Remote files\n\nOn load `.lit` determines the `src` and `root` and checks both local file system ([[testing/LightningFS]]) and the remote host (ie GitHub pages, or local/remote server) and compares `last-updated` (or Stat `mtimeMs` in the case of local filesystem)\n\nThe problem is, that deployment to GitHub pages results in a remote file that *seems* newer than the local file that created it.\n\n## Potential solutions\n\n- Disable (appropriately) GitHub Pages cache\n\n  https://stackoverflow.com/questions/12556593/determining-a-page-is-outdated-on-github-pages\n- Read from api instead of pages static file server when Authenticated\n  - Potentially read and write to `gh-pages` directly, eschewing Actions deployment entirely.\n  - [x] Currently reading and writing to GitHub api when token is available. **Breaks reading generated files like : manifest.json**\n- Compare hashes of the content [stackoverflow crypto](https://stackoverflow.com/questions/18338890/are-there-any-sha-256-javascript-implementations-that-are-generally-considered-t/48161723#48161723)\n\n```txt test.txt remote=true < test.txt\nQ\n```\n```js\nreturn lit.fs.readFile('/manifest.json')\n```\n\n```js\nreturn JSON.stringify(lit.utils.diff.diffLines(lit.stats.local.value, lit.stats.remote.value, {\n  newlineIsToken: true,\n}), null, 2)\n```\n\n\n"
  },
  {
    "count": 1,
    "removed": true,
    "value": "\n"
  }
]