Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dev0ps's avatar

how to load svg file one time as page load and use same file for every ajax page load.

how to prevent loading same file again and again

0 likes
2 replies
Tray2's avatar

If not mistaken it's cached in the browser just like your js and css so it shouldn't be loaded fresh every time from the server.

Dev0ps's avatar
 #leverage browser caching
    ExpiresActive on
    ExpiresDefault A300

    # Perhaps better to whitelist expires rules? Perhaps.
      ExpiresDefault "access plus 1 month"

    # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
      ExpiresByType text/cache-manifest "access plus 0 seconds"

    # Your document HTML
      ExpiresByType text/html "access plus 0 seconds"

    # Data
      ExpiresByType text/xml "access plus 0 seconds"
      ExpiresByType application/xml "access plus 0 seconds"
      ExpiresByType application/json "access plus 0 seconds"

    # Feed
      ExpiresByType application/rss+xml "access plus 1 hour"
      ExpiresByType application/atom+xml "access plus 1 hour"

    # Favicon (cannot be renamed)
      ExpiresByType image/x-icon "access plus 1 week"

    # Media: images, video, audio
      ExpiresByType image/gif "access plus 1 month"
      ExpiresByType image/png "access plus 1 month"
      ExpiresByType image/jpg "access plus 1 month"
      ExpiresByType image/jpeg "access plus 1 month"
      ExpiresByType video/ogg "access plus 1 month"
      ExpiresByType audio/ogg "access plus 1 month"
      ExpiresByType video/mp4 "access plus 1 month"
      ExpiresByType video/webm "access plus 1 month"

    # HTC files (css3pie)
      ExpiresByType text/x-component "access plus 1 month"

    # Web fonts
      ExpiresByType application/x-font-ttf "access plus 1 month"
      ExpiresByType font/opentype "access plus 1 month"
      ExpiresByType application/x-font-woff "access plus 1 month"
#      ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
      ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

    # CSS and JavaScript
      ExpiresByType text/css "access plus 1 year"
      ExpiresByType application/javascript "access plus 1 year"

      <IfModule mod_headers.c>
        Header append Cache-Control "public"
      </IfModule>

      # MIME TYPES
      <IfModule mod_mime.c>

        # DEFAULTS
        DefaultLanguage en
        AddLanguage en-US .html .css .js
        AddCharset utf-8 .html .css .js .xml .json .rss .atom

        # JAVASCRIPT
        AddType application/javascript js jsonp
        AddType application/json json

        # FONTS
        AddType font/opentype otf
        AddType application/font-woff woff
        AddType application/x-font-woff woff
        AddType application/vnd.ms-fontobject eot
        AddType application/x-font-ttf ttc ttf
        AddType image/svg+xml svg svgz
        AddEncoding gzip svgz

        # AUDIO
        AddType audio/mp4 m4a f4a f4b
        AddType audio/ogg oga ogg

        # VIDEO
        AddType video/mp4 mp4 m4v f4v f4p
        AddType video/ogg ogv
        AddType video/webm webm
        AddType video/x-flv flv

        # OTHERS
        AddType application/octet-stream safariextz
        AddType application/x-chrome-extension crx
        AddType application/x-opera-extension oex
        AddType application/x-shockwave-flash swf
        AddType application/x-web-app-manifest+json webapp
        AddType application/x-xpinstall xpi
        AddType application/xml atom rdf rss xml
        AddType application/vnd.openxmlformats .docx .pptx .xlsx .xltx . xltm .dotx .potx .ppsx
        AddType text/cache-manifest appcache manifest
        AddType text/vtt vtt
        AddType text/x-component htc
        AddType text/x-vcard vcf
        AddType image/webp webp
        AddType image/x-icon ico

      </IfModule>

its already there

Please or to participate in this conversation.