micronaut-projects / micronaut-session

Apache License 2.0
0 stars 0 forks source link

Session fetched for static assets #171

Open markosski opened 5 months ago

markosski commented 5 months ago

Issue description

Hello all! I noticed that some static assets get the session cookie returned in response. I have a custom implementation of session storage that stores data in database (instead of in-memory) and this behavior adds unnecessary load onto the database. I tested with default in memory session storage and the behavior is the same. Not sure if this is configuration issue or possibly a bug?

image image image
markosski commented 5 months ago

Looking through the code HttpSessionFilter execute on each request. I created the following to override this. Is this reasonable?

@Filter(patternStyle = FilterPatternStyle.REGEX, patterns = "(?!\\/static\\/).+")
@Replaces(HttpSessionFilter.class)
public class SessionFilter extends HttpSessionFilter {
    public SessionFilter(SessionStore<Session> sessionStore, HttpSessionIdResolver[] resolvers, HttpSessionIdEncoder[] encoders) {
        super(sessionStore, resolvers, encoders);
    }
}