Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

243
Vistas
how to caching javascript file

enter image description hereI have a large web application that was built about 9-8 years ago with "pug" technology, and in recent years pages have been added in an innovative framework (vue.js) Now in any transition between an old page (pug) and a vue page, the Webpack (version 3.12) loads a build.js file (3.8MB!) that Located in index.html and takes an average of 9 seconds to load and significantly Interferes with the UX.

is there any way I can save the build.js in the cache? or alternatively, I would love to hear if anyone has another idea that can enhance the user experience

the webserver of the site is Nginx

edit: here is my nginx file (the relevant parts)

server {
    listen      80;
    server_name xxx.com;
    return 301 https://xxx$request_uri;
}

server {
    listen       443 ssl;
    server_name xxx.com;

    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_min_length 1000;
      location ~ ^/dist/(?:ico|css|js|gif|jpe?g|png)$ {
        expires 30d;
    }
    location ~ ^/public/(\d+)/(.+)$ {
         try_files /lbo_builds/build_$1/public/$1/$2 =404;
    }

    location ~ ^/export/data/(.+)$ {
        gzip_static always;
        add_header Content-Encoding gzip;
        add_header Content-disposition attachment;
        try_files /lbo_exported_files/$1.gz =404;
    }

    location /customer_upload_document_proxy {
        proxy_set_header Cookie JSESSIONID=$cookie_jba_session;
        proxy_pass xxx;
    }

    location / {
        expires off;
        add_header Cache-Control "max-age=0, no-store, no-cache, must-revalidate";

        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_pass http://$backend_upstream$request_uri;
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

  1. Split the single huge build.js into small chunks to take advantage of browser’s parallel downloading.
  2. configure gzip compression and cache control with nginx
server {
    listen      80;
    server_name xxx.com;
    return 301 https://xxx$request_uri;
}

server {
    listen       443 ssl;
    server_name xxx.com;

    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_min_length 1000;

    location ~ ^/public/(\d+)/(.+)$ {
         try_files /lbo_builds/build_$1/public/$1/$2 =404;
    }

    location ~ ^/export/data/(.+)$ {
        gzip_static always;
        add_header Content-Encoding gzip;
        add_header Content-disposition attachment;
        try_files /lbo_exported_files/$1.gz =404;
    }

    location /customer_upload_document_proxy {
        proxy_set_header Cookie JSESSIONID=$cookie_jba_session;
        proxy_pass xxx;
    }

    location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires 30d;
        
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://$backend_upstream$request_uri;
    }

    location / {
        expires off;
        add_header Cache-Control "max-age=0, no-store, no-cache, must-revalidate";

        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_pass http://$backend_upstream$request_uri;
    }


}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda