Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some headers were missing when serving from cache #6955

Merged
merged 1 commit into from
Sep 9, 2015

Conversation

Chraneco
Copy link
Contributor

The setting of headers like 'Content-Type' is currently happening in method respond of class JApplicationWeb.

Unfortunately, the system cache plugin stores contents at event onAfterRender which is triggered before respond is executed. Therefore, certain headers are missing when serving from the cache.
This creates problems especially if we are serving content that is not of Content-Type text/html.

This pull request changes the plugin so that the cache is created only after these headers are set by using event onAfterRespond instead of onAfterRender.

Since gzip compression already happened at this point, the compressed contents are stored in the cache and therefore no further compression is necessary when serving cached contents. Thus, the second change in the plugin file.

For testing please make sure that everything works as before and check that the Content-Type header is also cached now.

Testing Instructions

  1. Install attached cache test component and access it in frontend (there's no backend part).
  2. Click on the presented link which takes you to an image which should be displayed fine (even after refreshing the page).
  3. Enable the cache plugin of Joomla! and ensure that debug mode is disabled and you aren't logged in in frontend.
  4. Refresh the page of the image a few times. => It won't be displayed correctly anymore.
  5. Apply the patch, clear the cache and do the same again => the image will be displayed even after refreshing.

@RickR2H
Copy link
Member

RickR2H commented Jul 11, 2015

hello @Chraneco

Thank you for your contribution.

Please provide clear test instructions to be able to test / reproduce this issue.
If no reply is received within 4 weeks we will close this issue.

Thanks for understanding!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6955.

@Chraneco
Copy link
Contributor Author

Yes, I added instructions above.

Unfortunately, it doesn't seem to be possible to add extensions archives as attachments here, so I added an issue on Joomlacode and attached the test component there:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=34149&start=0


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6955.

@RickR2H
Copy link
Member

RickR2H commented Aug 17, 2015

@Chraneco I tried the component but initially the image wouldn't show. I do get the link but when I click it I get an empty page... Hope you can fix the component. You can mail me component directly: rick@r2h.nl
afbeelding 4

@Chraneco
Copy link
Contributor Author

@RickR2H Sorry, the sample image in Joomla I was using was apparently deleted in one of the latest versions. I updated the component with a path to another image and sent it to your email address.

If it still doesn't work please check whether the image images/sampledata/fruitshop/apple.jpg exists in your Joomla installation (it's there in a fresh new instance).

Thanks for testing!

@RickR2H
Copy link
Member

RickR2H commented Aug 20, 2015

Patch works! Thanks @Chraneco for putting all the effort in making a component to test this PR.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6955.

@RichardR2H
Copy link

Works here! Thanks.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6955.

@zero-24
Copy link
Contributor

zero-24 commented Aug 23, 2015

RTC based on tests by @RickR2H and @RichardR2H.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6955.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 23, 2015
@zero-24 zero-24 added this to the Joomla! 3.4.4 milestone Aug 25, 2015
@Kubik-Rubik Kubik-Rubik modified the milestones: Joomla! 3.4.5, Joomla! 3.4.4 Sep 3, 2015
roland-d added a commit that referenced this pull request Sep 9, 2015
Some headers were missing when serving from cache
@roland-d roland-d merged commit 44d22db into joomla:staging Sep 9, 2015
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Sep 9, 2015
@zero-24 zero-24 modified the milestones: Joomla! 3.4.6, Joomla! 3.5.0 Oct 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants