refactor settings use and move compress to first middleware