Code Monkey home page Code Monkey logo

Comments (5)

h2non avatar h2non commented on July 28, 2024

Please, see #33.

That being said, I don't have a clear idea about the scope of the feature you want to cover here.

from imaginary.

Dynom avatar Dynom commented on July 28, 2024

I don't propose a caching layer in Imaginary. Rather only HTTP caching headers.

So, whenever I do something like:

> GET /crop?width=290&height=218&file=c76/6ba/cf/6a0cb5df&type=jpeg&quality=85 HTTP/1.1
> Host: imaginary.example.org
> User-Agent: curl/7.43.0
> Accept: */*
>

The reply would read:

< HTTP/1.1 200 OK
< Content-Type: image/jpeg
< Date: Fri, 30 Oct 2015 08:56:17 GMT
< Server: imaginary 0.1.14 (bimg 0.1.19)
< transfer-encoding: chunked
< Connection: keep-alive
< Cache-Control: public, max-age=31536000
< Expires: Wed, 26 Oct 2016 22:00:23 GMT
< Last-Modified: Fri, 28 Aug 2015 21:45:00 GMT
< Vary: Origin

Where the last 4 headers would be the significant part.

Now that I think about it, just specifying a static list of arbitrary headers would be sufficient. But I'm now thinking if this is something Imaginary should support or not. I see some other use-cases (like origin identification), but I'm not sure if that justifies this feature.

To illustrate even further, Imaginary could've been started like so:

docker run \
...
HTTP_CACHE_CONTROL=Cache-Control: public, max-age=31536000
HTTP_EXPIRES_TIMESTAMP=Wed, 26 Oct 2016 22:00:23 GMT
HTTP_LAST_MODIFIED_TIMESTAMP=Fri, 28 Aug 2015 21:45:00 GMT
HTTP_VARY=Origin

from imaginary.

h2non avatar h2non commented on July 28, 2024

I see now. In that case, this would be only valid when imaginary relies on the file system to read the images, so we can use FileInfo to retrieve the Last-Modified header, for instance.

Then, I believe we can simplify the other headers just adding an additional option with the cache TTL.
I believe that this should be only supported if imaginary is using the file system, otherwise is useless and a bit incongruent.

I would not mind supporting this feature if it's clean and simple to use, so feel free to go ahead with a PR.

from imaginary.

Dynom avatar Dynom commented on July 28, 2024

Excellent. I'm fairly inexperienced with Go, but feel free to lay it on me in the PR (-:

Before I'll start I'll make a small specification to make sure it's heading the way you want.

from imaginary.

h2non avatar h2non commented on July 28, 2024

Sounds great!

from imaginary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.