PowerShell / PowerShellGallery

228 stars 65 forks source link

Avoid permanent redirect to current version #74

Open mlocati opened 4 years ago

mlocati commented 4 years ago

When browsing to the URL of a package on powershellgallery.com, the server returns a 301 Moved Permanently redirect to the latest version:

C:\>curl -I https://www.powershellgallery.com/packages/PhpManager
HTTP/1.1 301 Moved Permanently
Cache-Control: private
Content-Length: 148
Content-Type: text/html; charset=utf-8
Location: /packages/PhpManager/1.21.0.266
Server: Microsoft-IIS/10.0
Content-Security-Policy: frame-ancestors 'none'
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
Date: Fri, 29 Nov 2019 11:02:19 GMT

That implies that, when a new package version is released, and we browse to the package url again, we are redirected to the previous version (because of the permanent redirect).

What about using a 302 (or 307) redirect instead?

bormm commented 3 years ago

That explains exactly my issue I have. I had to clear my browser cache to get redirected to the latest version, otherwise I got the oldest and already unlisted version, because that was the first one was permanently redirected to. That is really a big issue as customers will possibly install old and even unlisted versions instead newer one, if they pick the recommended cmdline that installs the old version. Its also an issue as nobody understands what happens without deeper investigations.

dahlbyk commented 3 years ago

That implies that, when a new package version is released, and we browse to the package url again, we are redirected to the previous version (because of the permanent redirect).

What about using a 302 (or 307) redirect instead?

In addition to browser caching, the 301 is also respected by search engines to show old versions, e.g. image

tcartwright commented 3 years ago

I am experiencing this issue as well. Actually found this by googling powershellgallery 301 redirect. My vote goes to using a 302 like @dahlbyk suggested. Is there a valid reason for using a 301?