We have a customised process that relies on a cookie to render some pivotal display options. This is the only real solution as is required for all website guests.
Process works beautifully with FPC disabled, but with it enabled the PHP global $_COOKIE is cached for the entire browser session.
Essentially - we need to apply a patch to FPC to make it ignore cookies (either all or by name - either is fine for now).
Appreciate if anyone has had any success in achieving something similar, or a suitable place to start.
Note: running EE1.12 on AWS nginx build.
Cheers,
t8
In FPC with no Dynamic Block Magento application initialization is not done.
So as you want some part of your page to vary depending on Cookies you need to use Dynamic Block.
For this you will have to create a container class and set lifetime as Null as in snippet below
1.Try adding this to your container class: protected function _saveCache($data, $id, $tags = array(), $lifetime = null) { return false; } That should prevent it from getting cached.
Also this link on Stackoverflow :
How do I include a dynamic block in the product page with full page caching turned on?
details out on Dynamic Blocks and FPC.
Related
I keep having this problem:
Customers can not register, login and logout without an fatal error (enabled debugging).
Fatal error: Call to a member function setCustomerId() on a non-object in ../public_html/app/code/core/Mage/Reports/Model/Product/Index/Abstract.php on line 169
Here is the code snippet from lines 161 - 180:
/**
* Calculate count of product index items cache
*
* #return Mage_Reports_Model_Product_Index_Abstract
*/
public function calculate()
{
$collection = $this->getCollection()
->setCustomerId($this->getCustomerId())
->addIndexFilter();
Mage::getSingleton('catalog/product_visibility')
->addVisibleInSiteFilterToCollection($collection);
$count = $collection->getSize();
$this->_getSession()->setData($this->_countCacheKey, $count);
return $this;
}
What i've done, thanks to answers on similar questions:
Cookie settings.
Disabled (all) modules, one by one. By xml, admin backend and deleting. Also checked if there were any updates (there were not).
Refreshed cache, deleted cache, disabled cache (same for sessions)
Set Var directory, media, downloader and eventually all folders and files to 777.
Set all the correct permissions back again, thanks to magento-cleanup.php.
Checked the database on wrong base url's, secured and unsecured.
Did a complete app directory rewrite, uploaded from a clean magento installation.
Checked the server settings with , no safe modus (do got a basedir open directory)
Also i'm being redirected tot a 404 page within the backend. With a NoRoute URL, after a correct login. I do see and can use everything in the backend, including the navigation menu.
I do use a template and some customisation with plugins / modules. No coding in core files. Not sure what information is needed, so do ask if i have to mention something.
I'm completely lost after 8 hours of struggling. Hope it is something you can help me with.
Judging by the debug of calling the collection, you have either:
a) the issue with factory and xml (most likely, it the config.xml of some extension). In this case, you should debug the method _getResourceModelFactoryClassName of the core/config model.
https://www.gyazo.com/e7c8ebb26326ce2f1a3c7c26b43812ea
OR
b) the following class is absent: Mage_Reports_Model_Resource_Product_Index_Compared_Collection
https://www.gyazo.com/9c59119fe4b97889cb81d2e8980b55fa
You may check that in the getModelInstance method of the model. Please take into account the fact that while debuging via echo/var_dump you won't be able to good results, since these methods are generally called everywhere by different models.
I'd rather recommend you to start from checking the presence of the following class:
Mage_Reports_Model_Resource_Product_Index_Compared_Collection (app/code/core/mage/reports/model/resource/product/index/compared/collection.php).
Next, I'd check the presence of model rewrites in the (Mage_Reports) extension + check all recently installed extensions/ implemented changes in config.xml files of these modules.
Hope it helps.
Just debug and check what is returned in this method:
1) get_class($this)
2) get_class($this->getCollection())
In your case the error means the following: there's no a set resource model for the current model. The code is trying to access the collection, but can't do that, as there's no the required resource model, or the name of the resource model, or the class that corresponds to this name.
I'm trying to get my MVC3 site to redirect from HTTPS back to HTTP when the user browses to a page where it's not required (and they aren't logged in). I Don't want to have the load of running the whole site HTTPS but it's looking like thats the way I'll have to go.
I've been having loads of trouble with remote debug and symbols, but having gone back in time to 1985 and using message box equivalents to debug with I've come to the following conclusion:
if (filterContext.ActionDescriptor
.GetCustomAttributes(typeof(RequireHttpsAttribute), true)
.Any()
)
{
return true;
}
return false;
Always returns false.
The controller def starts as:
[FilterIP(
ConfigurationKeyAllowedSingleIPs = "AllowedAdminSingleIPs",
ConfigurationKeyAllowedMaskedIPs = "AllowedAdminMaskedIPs",
ConfigurationKeyDeniedSingleIPs = "DeniedAdminSingleIPs",
ConfigurationKeyDeniedMaskedIPs = "DeniedAdminMaskedIPs"
)]
[RequireHttps]
public class AccountController : Controller
{
And it doesn't seem to work for any actions in this controller (although they do get successfully routed to SSL).
Any suggestions? I'd love to see an answer for what I perceive as my own nubery ;)
Custom NotRequreHttpsAttribute tutorial
I use the above link post to implement my custom attribute, and redirect from https to http. Hope this helps.
My problem was discovered to be related to the bindings on the server published to. We use the same server for stage and production, and the stage https bindings were not set, so whenever it was calling an https page it was resolving into our production site (which looked the same so it was hard to spot).
Once I added a binding it was all solved. My code was ok...
Because of european privacy law being harsly applied in the Netherlands and to keep my company's site user friendly without nagging the users with questions if it's okay to store a cookie on their computer that allows me to access their client data.
What I need is a way to "overwrite" the native php sessions class so that at the point where the native class requests the cookie that stores the phpsessid, that I can place my own code there that checks the browsers fingerprint and matches that to a session id which I can use to return the normal working of the native class.
My idea is:
table sess_fingerprints
Fields: fingerprint - phpsessid
function getsessionid()
{
$result = $this->db->query("SELECT phpsessid
FROM `sessiondatabase`.`sess_fingerprints`
WHERE `sess_fingerprints`.`fingerprint` = '$userfingerprint'");
if($result->num_rows() != 0)
{
return $result->row->phpsessid;
}
}
and at that point the native php session code just works as it would normally do.
So, my question is: is it possible to overwrite only the "cookie" part of the phpsession class? if so, how? because I haven't found that yet.
I'm aware of being able to pass along the session variable via urls etc, but that's not secure enough for my web applications.
PHP provides support for custom session handlers:
http://php.net/manual/en/session.customhandler.php
I think I have found the solution to my problem.
I'm going to override the functions related to cookies by using http://php.net/manual/en/function.override-function.php
Thank you all for thinking along.
I'm using the jQuery .get() function to load in a template file and then display the loaded HTML into a part of the page by targeting a particular DOM element. It works well but I've recently realised for reasons that confound me that it is caching my template files and masking changes I have made.
Don't get me wrong ... I like caching as much as the next guy. I want it to cache when there's no timestamp difference between the client's cache and the file on the server. However, that's not what is happening. To make it even odder ... using the same function to load the templates ... some template files are loading the updates and others are not (preferring the cached version over recent changes).
Below is the loading function I use.
function LoadTemplateFile ( DOMlocation , templateFile , addEventsFlag ) {
$.get( templateFile , function (data) {
$( DOMlocation ).html(data);
});
}
Any help would be greatly appreciated.
NEW DETAILS:
I've been doing some debugging and now see that the "data" variable that comes back to the success function does have the newer information but for reasons that are not yet clear to me what's inserted into the DOM is an old version. How in heck this would happen has now become my question.
You can set caching to off in the jQuery.get() call. See the jQuery.ajax() doc for details with the cache: false option. The details of how caching works is browser specific so I don't think you can control how it works, just whether it's on or off for any given call.
FYI, when you turn caching off, jQuery bypasses the browser caching by appending a unique timestamp parameter to the end of the URL which makes it not match any previous URL, thus there is no cache hit.
You can probably also control cache lifetime and several other caching parameters on your server which will set various HTTP headers that instruct the browser what types of caching to allow. When developing your app, you probably want caching off entirely. For deployment, I would suggest that you want it on and then when you rev your app, the safest way to deal with caching is to change your URLs slightly so the new versions of your URLs are different. That way, you always get max caching, but also users get new versions immediately.
$get will always cache by default, especially on IE. You will need to manually append a querystring, or use the ajaxSetup method to bust the cache.
As an alternative, I found in the jQuery docs that you can just override the default caching. For me I didn't have to convert all of my $.get over to $.ajax calls. Note that this also overrides default behavior for all other types of calls, like $.getScript which has the opposite default behavior of cache: false from $.get.
https://api.jquery.com/jquery.getscript/
$.ajaxSetup({
cache: false
});
I am developing a http module that hooks into the FormsAuthentication Module through the Authenticate event.
While debugging i noticed that the module (and all other modules registered) gets hit every single time the client requests a resource (also when it requests images, stylesheets, javascript files (etc.)).
This happens both when running on a IIS 7 server in integrated pipeline mode, and debugging through the webdev server (in non- integrated pipeline mode)
As i am developing a website with a lot images which usually wont be cached by the client browser it will hit the modules a lot of unnessecary times.
I am using MVC and its routing mechanishm (System.Web.Routing.UrlRoutingModule).
When creating a new website the runAllManagedModulesForAllRequests attribute for the IIS 7 (system.webServer) section is per default set to true in the web.config, which as the name indicates make it call all modules for every single request.
If i set the runAllManagedModulesForAllRequests attribute to false, no modules will get called.
It seems that the reason for this is because of the routing module or mvc (dont know excactly why), which causes that the asp.net (aspx) handler never gets called and therefore the events and the modules never gets called (one time only like supposed).
I tested this by trying to call "mydomain.com/Default.aspx" instead of just "mydomain.com/" and correctly it calls the modules only once like it is supposed.
How do i fix this so it only calls the modules once when the page is requested and not also when all other resources are requested ?
Is there some way i can register that all requests should fire the asp.net (aspx) handler, except requests for specific filetype extensions ?
Of course that wont fix the problem if i choose to go with urls like /content/images/myimage123 for the images (without the extension). But i cant think of any other way to fix it.
Is there a better way to solve this problem ?
I have tried to set up an ignoreRoute like this routes.IgnoreRoute("content/{*pathInfo}"); where the content folder contains all the images, javascripts and stylesheets in seperat subfolders, but it doesnt seem to change anything.
I can see there a many different possibilites when setting up a handler but I cant seem to figure out how it should be possible to setup one that will make it possible to use the routing module and have urls like /blog/post123 and not call the modules when requesting images, javascripts and stylesheets (etc.).
Hope anyone out there can help me ?
Martin
The problem seems to be the routing module.
The solution is to move images, css, js to a subdomain, or you can probably register which filetypes/extensions the routing module should ignore.
The following code is what I use in every MVC Application in order to avoid the overhead caused by the routing system on serving static files, javascript, css, etc:
public static void RegisterRoutes(RouteCollection routes)
{
routes.RouteExistingFiles = false;
routes.LowercaseUrls = true;
routes.AppendTrailingSlash = true;
routes.IgnoreRoute("Content/{*pathInfo}");
routes.IgnoreRoute("Scripts/{*pathInfo}");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = #"(.*/)?favicon.ico(/.*)?" });
/* ... */
}