Web server serves up PDF file as wrong mime typehow to prvent specific pages from being cached in squid?Apache Content-Type encoding changing from UTF-8 to iso-88591 from directory to directoryNGINX MIME TYPEApache/2.2.20 (Ubuntu 11.10) gzip compression won't work on php pages, content is chunkedOne single page showing 3 requests (also printing the headers)How mod_cache working with “must-revalidate” and “max-age”?My Apache 2.2 local test server with php none cgi automaticly removes logged in ipad usersWrong mime-type for css and js filesApache / Nginx / Varnish - GZIP does not work on css, jsApache returning incorrect mime type for meta-data.xml.md5
Children's short story about material that accelerates away from gravity
Symbol for "not absolutely continuous" in Latex
How exactly is a normal force exerted, at the molecular level?
Signing using digital signatures?
How should I behave to assure my friends that I am not after their money?
“Faire” being used to mean “avoir l’air”?
How can I check type T is among parameter pack Ts... in C++?
One folder two different locations on ubuntu 18.04
Dold-Kan correspondence in the category of symmetric spectra
Zombie Diet, why humans
Should I hide continue button until tasks are completed?
How can I convince my reader that I will not use a certain trope?
Going to get married soon, should I do it on Dec 31 or Jan 1?
What is the line crossing the Pacific Ocean that is shown on maps?
Should I report a leak of confidential HR information?
What happens when your group is victim of a surprise attack but you can't be surprised?
Avoid bfseries from bolding pm in siunitx
Averting Real Women Don’t Wear Dresses
Cross over of arrows in a complex diagram
Wilcoxon signed rank test – critical value for n>50
What shortcut does ⌦ symbol in Camunda macOS app indicate and how to invoke it?
How to convert object fill in to fine lines?
How come I was asked by a CBP officer why I was in the US when leaving?
Professor Roman gives unusual math quiz ahead of
Web server serves up PDF file as wrong mime type
how to prvent specific pages from being cached in squid?Apache Content-Type encoding changing from UTF-8 to iso-88591 from directory to directoryNGINX MIME TYPEApache/2.2.20 (Ubuntu 11.10) gzip compression won't work on php pages, content is chunkedOne single page showing 3 requests (also printing the headers)How mod_cache working with “must-revalidate” and “max-age”?My Apache 2.2 local test server with php none cgi automaticly removes logged in ipad usersWrong mime-type for css and js filesApache / Nginx / Varnish - GZIP does not work on css, jsApache returning incorrect mime type for meta-data.xml.md5
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Following an upgrade to the latest version of Joomla, downloads from a website I am working on are being served incorrectly.
Example page: http://www.pacificpolicy.org/index.php?option=com_content&view=article&id=259:mic-paper&catid=39:rokfeature
They are being served up with the correct content-disposition on first visit, but any further visits PDF files are being loaded as text/html (i.e. displaying the file's contents on screen).
How can I force the browser to load the PDF correctly on each visit? My knowledge of PHP & http headers is pretty rudimentary, so I could use some help diagnosing this.
The host is a LAMP server, Joomla is 1.5.22, doc management plugin is Rubberdoc.
Response header on second visit reads:
Date: Thu, 16 Dec 2010 04:29:03 GMT
Server: Apache/XXx
X-Powered-By: PHP/xxx
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Etag: db71388c6fc952682ae2fd733d4b09c5
Content-Encoding: gzip
X-Content-Encoded-By: Joomla! 1.5
Expires: Mon, 1 Jan 2001 00:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Host
Last-Modified: Thu, 16 Dec 2010 04:29:03 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
And the download docs are called from a PHP file, which goes thusly:
<?php
// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the RubberDoc component
*
* @static
* @package Joomla
* @subpackage RubberDoc
* @since 1.0
*/
class RubberDocViewDoc extends JView
public function display($tpl = null)
global $mainframe, $option;
$id = JRequest::getInt('id');
if(!$id)
JError::raiseError(404, 'Page Not Found');
return;
$model =& $this->getModel('doc');
$model->hit();
$data =& $model->getData();
$fileName =& $data->get('file');
$dirname = $mainframe->getParams('com_rubberdoc')->get('rubberdoc_dir', 'rubberdoc');
$filePath = JPath::clean( JPATH_SITE.DS.$dirname.DS.$fileName );
if( !JFile::exists( $filePath ) )
JError::raiseError(404, 'Page Not Found');
return;
$fileName = $data->get('file');
$extension = array_pop( explode('.', $fileName) );
$fileName = $data->get('alias').'.'.$extension;
$fileContent = JFile::read( $filePath );
$fileSize = strlen($fileContent);
require(JPATH_COMPONENT.DS.'helpers'.DS.'mime.mapping.php');
$mime = $mime_extension_map[$extension]; //application/octet-stream
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
$doc =& JFactory::getDocument();
$doc->setMimeEncoding( $mime );
$doc->setModifiedDate( $data->get('modified') );
$doc->render();
header('Content-Disposition: attachment; filename="'.$fileName.'" ');
header('Content-Length: '. $fileSize);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Transfer-Encoding: binary');
if( ! ini_get('safe_mode') ) // set_time_limit doesn't work in safe mode
@set_time_limit(0);
echo $fileContent;
Thanks,
Nick
Port Vila, Vanuatu
apache-2.2 php http-headers joomla mime-type
add a comment |
Following an upgrade to the latest version of Joomla, downloads from a website I am working on are being served incorrectly.
Example page: http://www.pacificpolicy.org/index.php?option=com_content&view=article&id=259:mic-paper&catid=39:rokfeature
They are being served up with the correct content-disposition on first visit, but any further visits PDF files are being loaded as text/html (i.e. displaying the file's contents on screen).
How can I force the browser to load the PDF correctly on each visit? My knowledge of PHP & http headers is pretty rudimentary, so I could use some help diagnosing this.
The host is a LAMP server, Joomla is 1.5.22, doc management plugin is Rubberdoc.
Response header on second visit reads:
Date: Thu, 16 Dec 2010 04:29:03 GMT
Server: Apache/XXx
X-Powered-By: PHP/xxx
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Etag: db71388c6fc952682ae2fd733d4b09c5
Content-Encoding: gzip
X-Content-Encoded-By: Joomla! 1.5
Expires: Mon, 1 Jan 2001 00:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Host
Last-Modified: Thu, 16 Dec 2010 04:29:03 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
And the download docs are called from a PHP file, which goes thusly:
<?php
// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the RubberDoc component
*
* @static
* @package Joomla
* @subpackage RubberDoc
* @since 1.0
*/
class RubberDocViewDoc extends JView
public function display($tpl = null)
global $mainframe, $option;
$id = JRequest::getInt('id');
if(!$id)
JError::raiseError(404, 'Page Not Found');
return;
$model =& $this->getModel('doc');
$model->hit();
$data =& $model->getData();
$fileName =& $data->get('file');
$dirname = $mainframe->getParams('com_rubberdoc')->get('rubberdoc_dir', 'rubberdoc');
$filePath = JPath::clean( JPATH_SITE.DS.$dirname.DS.$fileName );
if( !JFile::exists( $filePath ) )
JError::raiseError(404, 'Page Not Found');
return;
$fileName = $data->get('file');
$extension = array_pop( explode('.', $fileName) );
$fileName = $data->get('alias').'.'.$extension;
$fileContent = JFile::read( $filePath );
$fileSize = strlen($fileContent);
require(JPATH_COMPONENT.DS.'helpers'.DS.'mime.mapping.php');
$mime = $mime_extension_map[$extension]; //application/octet-stream
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
$doc =& JFactory::getDocument();
$doc->setMimeEncoding( $mime );
$doc->setModifiedDate( $data->get('modified') );
$doc->render();
header('Content-Disposition: attachment; filename="'.$fileName.'" ');
header('Content-Length: '. $fileSize);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Transfer-Encoding: binary');
if( ! ini_get('safe_mode') ) // set_time_limit doesn't work in safe mode
@set_time_limit(0);
echo $fileContent;
Thanks,
Nick
Port Vila, Vanuatu
apache-2.2 php http-headers joomla mime-type
add a comment |
Following an upgrade to the latest version of Joomla, downloads from a website I am working on are being served incorrectly.
Example page: http://www.pacificpolicy.org/index.php?option=com_content&view=article&id=259:mic-paper&catid=39:rokfeature
They are being served up with the correct content-disposition on first visit, but any further visits PDF files are being loaded as text/html (i.e. displaying the file's contents on screen).
How can I force the browser to load the PDF correctly on each visit? My knowledge of PHP & http headers is pretty rudimentary, so I could use some help diagnosing this.
The host is a LAMP server, Joomla is 1.5.22, doc management plugin is Rubberdoc.
Response header on second visit reads:
Date: Thu, 16 Dec 2010 04:29:03 GMT
Server: Apache/XXx
X-Powered-By: PHP/xxx
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Etag: db71388c6fc952682ae2fd733d4b09c5
Content-Encoding: gzip
X-Content-Encoded-By: Joomla! 1.5
Expires: Mon, 1 Jan 2001 00:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Host
Last-Modified: Thu, 16 Dec 2010 04:29:03 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
And the download docs are called from a PHP file, which goes thusly:
<?php
// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the RubberDoc component
*
* @static
* @package Joomla
* @subpackage RubberDoc
* @since 1.0
*/
class RubberDocViewDoc extends JView
public function display($tpl = null)
global $mainframe, $option;
$id = JRequest::getInt('id');
if(!$id)
JError::raiseError(404, 'Page Not Found');
return;
$model =& $this->getModel('doc');
$model->hit();
$data =& $model->getData();
$fileName =& $data->get('file');
$dirname = $mainframe->getParams('com_rubberdoc')->get('rubberdoc_dir', 'rubberdoc');
$filePath = JPath::clean( JPATH_SITE.DS.$dirname.DS.$fileName );
if( !JFile::exists( $filePath ) )
JError::raiseError(404, 'Page Not Found');
return;
$fileName = $data->get('file');
$extension = array_pop( explode('.', $fileName) );
$fileName = $data->get('alias').'.'.$extension;
$fileContent = JFile::read( $filePath );
$fileSize = strlen($fileContent);
require(JPATH_COMPONENT.DS.'helpers'.DS.'mime.mapping.php');
$mime = $mime_extension_map[$extension]; //application/octet-stream
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
$doc =& JFactory::getDocument();
$doc->setMimeEncoding( $mime );
$doc->setModifiedDate( $data->get('modified') );
$doc->render();
header('Content-Disposition: attachment; filename="'.$fileName.'" ');
header('Content-Length: '. $fileSize);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Transfer-Encoding: binary');
if( ! ini_get('safe_mode') ) // set_time_limit doesn't work in safe mode
@set_time_limit(0);
echo $fileContent;
Thanks,
Nick
Port Vila, Vanuatu
apache-2.2 php http-headers joomla mime-type
Following an upgrade to the latest version of Joomla, downloads from a website I am working on are being served incorrectly.
Example page: http://www.pacificpolicy.org/index.php?option=com_content&view=article&id=259:mic-paper&catid=39:rokfeature
They are being served up with the correct content-disposition on first visit, but any further visits PDF files are being loaded as text/html (i.e. displaying the file's contents on screen).
How can I force the browser to load the PDF correctly on each visit? My knowledge of PHP & http headers is pretty rudimentary, so I could use some help diagnosing this.
The host is a LAMP server, Joomla is 1.5.22, doc management plugin is Rubberdoc.
Response header on second visit reads:
Date: Thu, 16 Dec 2010 04:29:03 GMT
Server: Apache/XXx
X-Powered-By: PHP/xxx
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Etag: db71388c6fc952682ae2fd733d4b09c5
Content-Encoding: gzip
X-Content-Encoded-By: Joomla! 1.5
Expires: Mon, 1 Jan 2001 00:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Host
Last-Modified: Thu, 16 Dec 2010 04:29:03 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
And the download docs are called from a PHP file, which goes thusly:
<?php
// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the RubberDoc component
*
* @static
* @package Joomla
* @subpackage RubberDoc
* @since 1.0
*/
class RubberDocViewDoc extends JView
public function display($tpl = null)
global $mainframe, $option;
$id = JRequest::getInt('id');
if(!$id)
JError::raiseError(404, 'Page Not Found');
return;
$model =& $this->getModel('doc');
$model->hit();
$data =& $model->getData();
$fileName =& $data->get('file');
$dirname = $mainframe->getParams('com_rubberdoc')->get('rubberdoc_dir', 'rubberdoc');
$filePath = JPath::clean( JPATH_SITE.DS.$dirname.DS.$fileName );
if( !JFile::exists( $filePath ) )
JError::raiseError(404, 'Page Not Found');
return;
$fileName = $data->get('file');
$extension = array_pop( explode('.', $fileName) );
$fileName = $data->get('alias').'.'.$extension;
$fileContent = JFile::read( $filePath );
$fileSize = strlen($fileContent);
require(JPATH_COMPONENT.DS.'helpers'.DS.'mime.mapping.php');
$mime = $mime_extension_map[$extension]; //application/octet-stream
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
$doc =& JFactory::getDocument();
$doc->setMimeEncoding( $mime );
$doc->setModifiedDate( $data->get('modified') );
$doc->render();
header('Content-Disposition: attachment; filename="'.$fileName.'" ');
header('Content-Length: '. $fileSize);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Transfer-Encoding: binary');
if( ! ini_get('safe_mode') ) // set_time_limit doesn't work in safe mode
@set_time_limit(0);
echo $fileContent;
Thanks,
Nick
Port Vila, Vanuatu
apache-2.2 php http-headers joomla mime-type
apache-2.2 php http-headers joomla mime-type
asked Dec 16 '10 at 4:42
nick
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It's hard to say for sure, but I would suspect that on the first visit they are being served by the java code, which sets the correct mime type. After that, there's likely some caching going on which is not setting the correct mime type. See if you have any PDF files floating around on disk. If so, you need to look at apache's configuration, not your code.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f213157%2fweb-server-serves-up-pdf-file-as-wrong-mime-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's hard to say for sure, but I would suspect that on the first visit they are being served by the java code, which sets the correct mime type. After that, there's likely some caching going on which is not setting the correct mime type. See if you have any PDF files floating around on disk. If so, you need to look at apache's configuration, not your code.
add a comment |
It's hard to say for sure, but I would suspect that on the first visit they are being served by the java code, which sets the correct mime type. After that, there's likely some caching going on which is not setting the correct mime type. See if you have any PDF files floating around on disk. If so, you need to look at apache's configuration, not your code.
add a comment |
It's hard to say for sure, but I would suspect that on the first visit they are being served by the java code, which sets the correct mime type. After that, there's likely some caching going on which is not setting the correct mime type. See if you have any PDF files floating around on disk. If so, you need to look at apache's configuration, not your code.
It's hard to say for sure, but I would suspect that on the first visit they are being served by the java code, which sets the correct mime type. After that, there's likely some caching going on which is not setting the correct mime type. See if you have any PDF files floating around on disk. If so, you need to look at apache's configuration, not your code.
answered Dec 16 '10 at 5:17
devicenulldevicenull
5,2131 gold badge20 silver badges30 bronze badges
5,2131 gold badge20 silver badges30 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f213157%2fweb-server-serves-up-pdf-file-as-wrong-mime-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown