question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Static files rework

See original GitHub issue

Currently, you configure static files like this:

public JavalinConfig addStaticFiles(String classpathPath)
public JavalinConfig addStaticFiles(String path, Location location)
public JavalinConfig addStaticFiles(String urlPathPrefix, String path, Location location)

In addition you have some global properties:

public boolean precompressStaticFiles = false;
public ContextHandler.AliasCheck aliasCheckForStaticFiles = null;

And in addition to that (!), you have that files served from a dir called /immutable have the max-axe header set to 1 year.

It should be possible to clean this up a bit.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
tipsycommented, Apr 10, 2021

There was a suggestion on Discord to add static file handlers as normal get routes:

get(path, staticFilesHandler, roles)

0reactions
tipsycommented, May 1, 2021

Current API:

javalin.addStaticFiles { staticFiles ->
    staticFiles.hostedPath = "/url-prefix"
    staticFiles.directory = "/public"
    staticFiles.location = Location.CLASSPATH
    staticFiles.aliasCheck = ContextHandler.ApproveAliases()
    staticFiles.precompress = true
    staticFiles.headers = mapOf(Header.CACHE_CONTROL to "max-age=31622400")
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to manage static files (e.g. images, JavaScript, CSS)
Configuring static files¶ · Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS . · In your settings file, define STATIC_URL , for ......
Read more >
Django won't refresh staticfiles - Stack Overflow
I would see the original base.css but no my update to file.This is on a dev environment. I did not think django cached...
Read more >
Static files rework · Issue #1223 · javalin/javalin - GitHub
Currently, you configure static files like this: public JavalinConfig addStaticFiles(String classpathPath) public JavalinConfig ...
Read more >
Django does not refresh edited static files - Reddit
Django does not refresh edited static files. Hey! In my settings I have the followings part: STATIC_URL = '/static/'.
Read more >
feat(boilerplate): Rework API files so static files work. Remove all ...
feat(boilerplate): Rework API files so static files work. Remove all "app.X" imports, and have manage.sh -r cd into the project directory instead of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found