1. Home
  2. Docs
  3. DFlip WordPress Plugin
  4. Issues and FAQs
  5. PDF optimization for faster loading

PDF optimization for faster loading

PDF not loading or Slow loading (no partial loading)

For better and fast experience – PDF is loaded on demand, If it is served as ‘gzip’ Whole PDF will be loaded – very bad user experience.

Also if the files are hosted in different domain name the you need to enable CORS:

For Apache Server, add following lines in .htaccess file

    Header set Access-Control-Allow-Origin "*" 
    Header set Access-Control-Allow-Headers "Range" 
    Header set Access-Control-Expose-Headers: "Accept-Ranges, Content-Encoding, Content-Length, Content-Range" 

More Info:

PHP server https://enable-cors.org/server_php.htmlOther Servers: https://enable-cors.org/server.html

For partial loading. disable gzip:

<IfModule mod_headers.c>
    <FilesMatch "\.pdf$">
        RewriteRule ^(.*)$ $1 [NS,E=no-gzip:1,E=dont-vary:1]
    </FilesMatch>
</IfModule>

reference: https://stackoverflow.com/questions/9249243/how-to-disable-apache-gzip-compression-for-some-media-files-in-htaccess-file

Was this article helpful to you? Yes No