Code Monkey home page Code Monkey logo

Comments (3)

fudanchii avatar fudanchii commented on August 19, 2024

As a workaround, for anyone using drone via reverse proxy like nginx.
You can always tell nginx to add Cache-Control no-cache header,
I use something like this on my instance:

    location ~ ^/img/build_.+\.png$ {
        proxy_pass http://drone;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For  $remote_addr;
        proxy_set_header Host $host;
        add_header Cache-Control no-cache;
    }

As for drone itself, it looks like we should use custom handler and use
http.ServeFile instead, then we can check r.URL.Path and set Cache-Control header
if it requests for /img/build_*.png. @bradrydzewski what do you think?

from gitness.

bradrydzewski avatar bradrydzewski commented on August 19, 2024

ahh, I might know the issue

We are setting cache-control headers for all requests:
https://github.com/drone/drone/blob/master/cmd/droned/drone.go#L178

However, this doesn't include our static assets:
https://github.com/drone/drone/blob/master/cmd/droned/drone.go#L73

We are serving the images using http.ServeFile:

http.Handle("/img/", http.FileServer(box.HTTPBox()))

We can probably wrap the FileServer in a function that, as you suggested, inspects the URL path and applies the cache-control header if /img/build_*.png

from gitness.

bradrydzewski avatar bradrydzewski commented on August 19, 2024

ok, added a fix here
https://github.com/drone/drone/blob/master/cmd/droned/drone.go#L80

from gitness.

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.