Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory listing pages' cache should be independently configurable (or deactivable) #133

Open
OdyX opened this issue May 25, 2023 · 6 comments

Comments

@OdyX
Copy link

OdyX commented May 25, 2023

When pushing assets to S3 buckets, the index directory listing pages as accessed via the nginx-s3-gateway stay cached for quite some time. When relying on the index directory listing pages to watch for most recent content, that kinda defeats the point.

@zc-devs
Copy link
Contributor

zc-devs commented May 26, 2023

What's about directory listing? :)

BTW, there is PROXY_CACHE_VALID_OK and also we can clear cache.

@OdyX
Copy link
Author

OdyX commented May 27, 2023

Yes. I was talking about directory listing, sorry. The problem with PROXY_CACHE_VALID_OK is that I want to cache static files from the s3 bucket as long as possible, but not cache the directory listing at all, and PROXY_CACHE_VALID_OK applies to both.

@OdyX OdyX changed the title Index pages' cache should be independently configurable (or deactivable) Directory listing pages' cache should be independently configurable (or deactivable) May 27, 2023
@zc-devs
Copy link
Contributor

zc-devs commented May 27, 2023

I've just played with configs...

We can just add proxy_no_cache 1; in common/etc/nginx/templates/gateway/s3listing_location.conf.template, rebuild image and use it.

  1. Generated listing pages are not cached, because of proxy_no_cache directive in @s3Listing location.
  2. S3 files are served by @s3 location and therefore are cached.

proxy_cache_valid should work too, I guess.

@OdyX
Copy link
Author

OdyX commented May 30, 2023

Indeed, that works (and possible in Kubernetes via a mounted ConfigMap file)

@dekobon
Copy link
Collaborator

dekobon commented Jun 23, 2023

Would you consider this issue solved?

@zc-devs
Copy link
Contributor

zc-devs commented Jun 23, 2023

in Kubernetes via a mounted ConfigMap file

We can use config below:

apiVersion: v1
kind: ConfigMap
metadata:
  name: ngs3gw-gw-templates
data:
  s3listing_location.conf.template: |
    proxy_no_cache 1;
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ngs3gw
spec:
  template:
    spec:
      containers:
        - name: ngs3gw
          image: nginxinc/nginx-s3-gateway:unprivileged-oss
          volumeMounts:
            - name: templates
              mountPath: /etc/nginx/templates/gateway/s3listing_location.conf.template
              subPath: s3listing_location.conf.template
      volumes:
        - name: templates
          configMap:
            name: ngs3gw-gw-templates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants