0

My css files named main.css?v=1.0.0 , site.css?=v.1.0 .

how to configure nginx to serve this kind of files(not extension with .css or .js but with a version number)

FYI:

all the files are in the right path and erro message in chrome dev tool console is file not found(404)

Thanks !

1 Answer 1

1

When you're trying to access main.css?v=1.0.0 or main.css?v=2.0.0 any webserver will point it to the same file, main.css . Well in your situation coud create a separate location for your versioned file, and then use the next code in the nginx config:

location = /main.css {
    if ($arg_v) {
        rewrite ([0-9]+) /where/maincss/versions/stored/main-$avg_v.css last;
    }
    // otherwise default main.css
}

The same thing'll be for the any other file

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.