Code Monkey home page Code Monkey logo

Comments (6)

maxhbr avatar maxhbr commented on June 25, 2024

note: One can enable serverside caching for nginx via:

diff --git a/deployment/sw360nginx/docker-entrypoint.sh b/deployment/sw360nginx/docker-entrypoint.sh   
index 0b51af5..f3ec720 100755                      
--- a/deployment/sw360nginx/docker-entrypoint.sh   
+++ b/deployment/sw360nginx/docker-entrypoint.sh   
@@ -32,9 +32,14 @@ if [ "$NGINX_CERTIFICATE" ] && [ "$NGINX_KEY_PRIV" ]; then                          
     fi                  
 fi                      
                         
+mkdir -p /data/nginx/cache                        
+                        
 ################################################################################                      
 ## generate /etc/nginx/conf.d/nginx-sw360.conf    
 cat <<EOF > "/etc/nginx/conf.d/nginx-${HOST}.conf"                                                    
+proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=sw360_cache:10m max_size=10g                  
+                 inactive=60m use_temp_path=off;  
+                        
 upstream ${HOST}-app {  
     server ${HOST}:${HOST_PORT} max_fails=3;      
 }                       
@@ -69,6 +74,8 @@ server {                         
         proxy_redirect off;                       
         proxy_pass  http://${HOST}-app;           
         proxy_read_timeout 3600s;                 
+                        
+        proxy_cache sw360_cache;                  
     }                   
 }                       
 EOF 

Whether this has a positive effect or whether this even leads to problems has to be checked.

from sw360chores.

maxhbr avatar maxhbr commented on June 25, 2024

Related Issue: sw360/sw360portal#397 "Implement a Benchmark to messure Tomcat performance"

from sw360chores.

maxhbr avatar maxhbr commented on June 25, 2024

Client side caching can be enforced via

diff --git a/deployment/sw360nginx/docker-entrypoint.sh b/deployment/sw360nginx/docker-entrypoint.sh
index 0b51af5..c3856e3 100755
--- a/deployment/sw360nginx/docker-entrypoint.sh
+++ b/deployment/sw360nginx/docker-entrypoint.sh
@@ -35,6 +35,14 @@ fi
 ################################################################################
 ## generate /etc/nginx/conf.d/nginx-sw360.conf
 cat <<EOF > "/etc/nginx/conf.d/nginx-${HOST}.conf"
+map \$sent_http_content_type \$expires {
+    default                    off;
+    text/html                  epoch;
+    text/css                   max;
+    application/javascript     max;
+    ~image/                    max;
+}
+
 upstream ${HOST}-app {
     server ${HOST}:${HOST_PORT} max_fails=3;
 }
@@ -69,6 +77,8 @@ server {
         proxy_redirect off;
         proxy_pass  http://${HOST}-app;
         proxy_read_timeout 3600s;
+
+        expires \$expires;
     }
 }
 EOF

from sw360chores.

mcjaeger avatar mcjaeger commented on June 25, 2024

the expires map did not work for me. as I tested the expires setting wth the dev tools browser. Have you tried it?

Another question would be for me to have the java scripts (and css) at max expiration for production. I suspect that updated css and Javascripts will not propagate then to the client?

from sw360chores.

mcjaeger avatar mcjaeger commented on June 25, 2024

OK, I see that the expiration does not count here, because the liferay requests use the timestamp syncing of the build time.

Question: did you observe improvements using the local proxy cache?

from sw360chores.

mcjaeger avatar mcjaeger commented on June 25, 2024

actually, I am not sure if the expires map proposal works, because eventually we found that the tomcat-served files are passed through at nginx and therefore the nginx needs to be configured as proxy rewrite.

location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        # proxy_hide_header expires;
        proxy_redirect off;
        proxy_pass  http://liferay-app;
        proxy_read_timeout 3600s;

        proxy_set_header expires 7d;
    }

from sw360chores.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.