Skip to content

net/http: provide an option to access /index.html directly without 301 redirect #53870

@ahuigo

Description

@ahuigo

What version of Go are you using (go version)?

$ go version
go1.18, go1.17, ...(may be all versions)

What did you do?

I found that https://github.com/golang/go/blob/master/src/net/http/fs.go#L590 will redirect /index.html to / with 301 status code.

This 301 action may cause some problems for service worker's cache(https://stackoverflow.com/questions/40476938/service-worker-breaking-301-redirects)

In order to stop 301 redirect, I had to hack official GONIC code

What did you expect to see?

PWA(web app) could cache the start_url:"/https/github.com/index.html" (301 redirect)

What did you see instead?

Since Service Worker breaking 301 redirects, my PWA app can't cache the start_url:"/https/github.com/index.html"

I think it's better to have an option an option to access /index.html directly without 301 redirect. (If possible, I could submit a PR)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions