GithubHelp home page GithubHelp logo

Comments (7)

serby avatar serby commented on September 25, 2024

I've never had this error. I'll try the upgrade and you can let me know if it fixes it.

from compact.

TrevorBurnham avatar TrevorBurnham commented on September 25, 2024

Hmm, I tried the pipe method and am still getting the same error. Definitely a bug somewhere beyond this library.

from compact.

TrevorBurnham avatar TrevorBurnham commented on September 25, 2024

After much frustration, I finally figured out the issue: The problem was that I was using the middleware in the order

app.use(compact.middleware(...));
app.use(express.static(...));

In which case, the compact middleware will recopy the files on every request (in debug mode)—including the requests to retrieve those files from the cache! The result is that the files are copied over as they're being served, leading to random errors.

The best workaround is to only use the compact middleware on requests for pages (swapping the order of the middleware should effectively do this), though this means that you have to load a page in order to see changes you've made to a script, which isn't ideal.

from compact.

serby avatar serby commented on September 25, 2024

I think the reason I don't observe this is because for my uses I don't use the global middleware and I don't have a need to view the compacted scripts.

By always applying compact on specific routes it will always be loaded after the static middleware.

from compact.

TrevorBurnham avatar TrevorBurnham commented on September 25, 2024

Makes sense. Might not be a bad idea to update the README, though. Other precompiler middlewares (like Stylus') are supposed to come before the static middleware, so I assumed compact's was as well.

On Nov 2, 2012, at 7:48 PM, Paul Serby [email protected] wrote:

I think the reason I don't observe this is because for my uses I don't use the global middleware and I don't have a need to view the compacted scripts.

By always applying compact on specific routes it will always be loaded after the static middleware.


Reply to this email directly or view it on GitHub.

from compact.

serby avatar serby commented on September 25, 2024

Done.

from compact.

TrevorBurnham avatar TrevorBurnham commented on September 25, 2024

You're a gentleman and a scholar.

from compact.

Related Issues (16)

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.