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

338
Vistas
Auto-Versioning inline Javascript in a PHP File?

I have the following question / problem: I know that if I append something like "?v=*" in my Javascript includes such as <script src="/js/myJsFile1.js?v=1.1" type="text/javascript"></script> I can force a client side recaching.

Now my question is, if I have a fragment such as the following in an example.php...

<?php ... ?> 
<script> 
    var a = 5; 
    callRandomFunction(); 
</script> 

...is there a need to have a version-control for this fragment as well? As it is included in a PHP File and therefore always called from the server anyway, does a forced caching make sense here?
If it does - Is there some similar way as there is with the "?v=" appendix?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A few points of confusion:

  • "caching" refers to re-using content; the techniques you are talking about are not "forced caching", they are forcing the browser not to use a cached copy
  • the parameter doesn't mean anything to the browser, it just means that this is a URL the browser has never seen before, so it won't have a cached copy
  • the browser doesn't see that something is part of a PHP page, only that it's part of an HTML page
  • the browser doesn't cache parts of pages, so if that HTML page is cached, the JS inside the page is cached too; if it is not, it is not
    • to be clear, JS served on a separate URL but referenced in the HTML page will be cached separately, which is why changing the URL for each version makes a difference

So, the question comes down to:

Will my HTML page be cached?

The answer depends on cache headers, which are a surprisingly complicated part of HTTP. But the short version is that PHP will generally set headers telling the browser not to cache pages it generates.

So the really short answer is: no, you don't need to do anything.

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