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

Add more options #8

Open
ahmdrz opened this issue Jan 15, 2018 · 10 comments
Open

Add more options #8

ahmdrz opened this issue Jan 15, 2018 · 10 comments

Comments

@ahmdrz
Copy link
Contributor

ahmdrz commented Jan 15, 2018

Hi ,
I want to add one more option, Expiration time , and there are two ways to implement it :

  1. Expiration time using Date header.
  2. Using until ... format in X-MINA-OPTIONS header.

In the first case , we can set a limit for each dumped file. For example , getting new response from target if the value of time.Now() - Date header is grater than EXPIRATION_TIME otherwise load from dumped file.

In the second case , Mina have to load dumped responses from corresponding requests that contain X-MINA-OPTIONS=until <DATE> header and Date header of dumped responses is grater than <DATE>.

To test Mina , I used it in inline app of Vajehyab so I need expiration time option.

What is your idea @siadat .

@siadat
Copy link
Member

siadat commented Jan 16, 2018

I'm all for expiration dates! I understand the second solution, could you explain the first one a bit more? How do we know if mina's cached version of a response is old enough to be expired?

@ahmdrz
Copy link
Contributor Author

ahmdrz commented Jan 16, 2018

How do we know if mina's cached version of a response is old enough to be expired?

In both cases , we have Date header in dump files. The algorithm is similar to this :

  1. Load dumped response.
  2. If Date header is older than ... ( فلان 😄) load new response from target otherwise load dumped response.

In first case , we have a global const that tell Mina do not load dumped responses that their Date header is older than ... ( فلان 😄)

I think second case is more better than first case.

@siadat
Copy link
Member

siadat commented Jan 16, 2018

So, does that mean to avoid having to read the response file we would need to keep the value of the cached response's Date header in memory?

@ahmdrz
Copy link
Contributor Author

ahmdrz commented Jan 16, 2018

No we don't need to save anything on memory , all of them are in disk.

But in first case , we can delete dump files.

@siadat
Copy link
Member

siadat commented Jan 16, 2018

time.Now() - Date

By reading this I'm guessing your are considering that Date values could be less than time.Now(). Could the value of the request's Date header be in the past? The Date is usually set to the date and time that the message was originated, so it's always almost equal to time.Now(), am I right?

If not, then please demonstrate your algorithm by a simple request that should be considered expired.

@ahmdrz
Copy link
Contributor Author

ahmdrz commented Jan 16, 2018

Mr Siadat. Sorry for my bad english , Maybe I can't tell you what is in my mind.
I will show you by code.

@ahmdrz
Copy link
Contributor Author

ahmdrz commented Jan 16, 2018

ahmdrz@1dc7105 and ahmdrz@b9d0333

Note: This is not completed

@siadat
Copy link
Member

siadat commented Jan 16, 2018

Cool @ahmdrz! The 2nd algorithm could be a bit difficult for clients to use, right? Because the clients will have to keep updating the "until" value once it is reached, otherwise mina will ignore cache for all subsequent requests that look like this:

X-MINA-OPTIONS: until ${an hour ago}

What do you think about supporting standard HTTP headers like Cache-Control?

@ahmdrz
Copy link
Contributor Author

ahmdrz commented Jan 16, 2018 via email

@siadat
Copy link
Member

siadat commented Jan 17, 2018

Lol it's okay. I think it would be a good idea to do a little bit of research about HTTP caching and proxy caching. Eg have a look at the http caching spec to see what is the recommended way to handle caches in proxies.

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

2 participants