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

ETag middleware #559

Closed
3 tasks
ebebbington opened this issue Jun 27, 2020 · 11 comments · Fixed by #568
Closed
3 tasks

ETag middleware #559

ebebbington opened this issue Jun 27, 2020 · 11 comments · Fixed by #568
Assignees

Comments

@ebebbington
Copy link
Member

Original issue: https://github.com/drashland/deno-drash/issues/17

Ported over here because @crookse decided to make it a middleware instead (which is a good call), because it means it's usuable by users, but doesn't affect drash's performance at all - win win scenario

What

Add a new middleware for supporting the ETag header

Why

  • Improves caching = improves request speed
  • Will not affect Drash's performance because Drash wouldn't have it built into the source code

How

  • File structure would look like:
deno-drash-middleware/
    etag/ <-- etag code here
        tests/
        deps.ts
        some_related_file.ts
        another_related_file.ts
        mod.ts
        README.md
    ...
  • Users would import the middleware like:

import { ETag } from "https://deno.land/x/drash-middleware@v{version}/etag/mod.ts"

  • Place third-party modules in your middleware directory's deps.ts file (if used)

  • Any Deno std module that's required by your package can be exported from the repo's root deps.ts file so that all middleware can import std modules from that single file.

Acceptance Criteria

  • README.md file showing how to use the middleware. Drash is a documentation-driven codebase, so the documentation is very important.

  • Develop ETag functionality

  • Tests

@diveDylan
Copy link

@ebebbington got it. ✋

@ebebbington
Copy link
Member Author

ebebbington commented Jun 28, 2020

@diveDylan Nice one! Be sure to read contributing for more information on tackling issues

@ebebbington
Copy link
Member Author

We're just in the process of updating the contributing documentation, just waiting for drashland/deno-drash-middleware#9 to be closed and it should give more information hoping its helpful :)

@diveDylan
Copy link

ye... I have read the doc for coding. It seems has a lot work on compare the cache state fresh or stale before set Etag on the response headers.

@ebebbington
Copy link
Member Author

I think how it would work is:

  1. If request has no etag and is a GET (avoid POST, DELETE, PUT due to dynamic data?):
    1.1. set etag with hashed timestamp, request method and url
  2. if request etag has expired (using decoded timestamp from the header)
    2.1. 'refresh', and go to point 1.1

Though i am not sure and might. be looking in the wrong direction, the implementation of ETag is confusing to me

@ebebbington
Copy link
Member Author

Heres some resources if it helps:

https://en.wikipedia.org/wiki/HTTP_ETag

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

If you want to discuss it in more detail then feel free to join our discord

@diveDylan
Copy link

@ebebbington i have read all the doc on your list before 😄

@ebebbington
Copy link
Member Author

Just thought it's worth mentioning!:)

@diveDylan
Copy link

@ebebbington haha. it is indeed!:)

@crookse crookse changed the title ETag Middleware feat: ETag middleware Oct 31, 2020
@crookse crookse changed the title feat: ETag middleware ETag middleware Nov 1, 2020
@ebebbington ebebbington transferred this issue from drashland/deno-drash-middleware Nov 2, 2021
@ebebbington
Copy link
Member Author

@diveDylan have you made any progress on this?

@diveDylan
Copy link

@diveDylan have you made any progress on this?

sorry, i forget this! I will join the discord and read contributing line. It is too late ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants